Return to Snippet

Revision: 56462
at March 29, 2012 10:35 by slolife


Initial Code
Sub ScanProjectsForTreatWarningsAsErrors()
        Const PaneName As String = "TreatWarningsAsErrors"
        Dim ow As OutputWindow = DTE.ToolWindows.OutputWindow
        Dim owp As OutputWindowPane = ow.OutputWindowPanes.Item(PaneName)
        If owp Is Nothing Then
            owp = ow.OutputWindowPanes.Add(PaneName)
        End If

        owp.Clear()
        owp.Activate()

        For Each project As Project In DTE.Solution.Projects
            ScanProject(project, owp)
            Exit For
        Next
    End Sub

    Sub ScanProject(ByVal project As Project, ByVal owp As OutputWindowPane)
        If (project.Kind = "{66A26720-8FB5-11D2-AA7E-00C04F688DDE}") Then
            For Each projectItem As ProjectItem In project.ProjectItems
                If Not (projectItem.SubProject Is Nothing) Then
                    ScanProject(projectItem.SubProject, owp)
                End If
            Next
        Else
            For Each config As Configuration In project.ConfigurationManager
                Dim value As Boolean = CType(config.Properties.Item("TreatWarningsAsErrors").Value, Boolean)
                If Not value Then
                    owp.OutputString("Project: " + project.Name + ", " + config.ConfigurationName)
                    owp.OutputString(" - TreatWarningsAsErrors = " + value.ToString())
                    owp.OutputString(vbCrLf)
                End If
            Next

            'For Each configProp As [Property] In project.ConfigurationManager.Item(1).Properties
            '    owp.OutputString(configProp.Name + vbCrLf)
            'Next
        End If
    End Sub

Initial URL
http://www.onlinescorekeeper.com/

Initial Description
VS.NET Macro to list all projects in current solution that have TreatWarningsAsErrors=false.

Initial Title
Find all TreatWarningsAsErrors=false projects

Initial Tags
c#

Initial Language
VB.NET