Search code examples
msbuildcode-analysisfxcop

Disable Code Analysis output MSBuild


I am building projects using a build definition. When this executes, Code Analysis is also performed. Code Analysis outputs various files including:

ConsoleApplication2.exe.CodeAnalysisLog.xml
ConsoleApplication2.exe.lastcodeanalysissucceeded

Is there any way to disable this output from happing in my build definition, say through parameters or something similar?


Solution

  • I have found an option for the lastcodeanalysissucceededfile.

    By providing an input parameter: /p:CodeAnalysisGenerateSuccessFile=false, the file does not get generated.

    I have yet to find an input parameter that disables the output of the logfile. The schemasettings as stated below did not cover it.

    <xs:element name="CodeAnalysisInputAssembly" type="msb:StringPropertyType" substitutionGroup="msb:Property">
        <xs:annotation>
            <xs:documentation><!-- _locID_text="CodeAnalysisInputAssembly" _locComment="" -->Path to the assembly to be analyzed by Code Analysis. The default is '$(OutDir)$(TargetName)$(TargetExt)'.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="CodeAnalysisLogFile" type="msb:StringPropertyType" substitutionGroup="msb:Property">
        <xs:annotation>
            <xs:documentation><!-- _locID_text="CodeAnalysisLogFile" _locComment="" -->Path to the output file for the Code Analysis report. The default is '$(CodeAnalysisInputAssembly).CodeAnalysisLog.xml'.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="CodeAnalysisLogFileXsl" type="msb:StringPropertyType" substitutionGroup="msb:Property">
        <xs:annotation>
            <xs:documentation><!-- _locID_text="CodeAnalysisLogFileXsl" _locComment="" -->Path to the XSL style sheet to reference in the Code Analysis output report. This report is specified in $(CodeAnalysisLogFile). The default is an empty string ('').</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="CodeAnalysisModuleSuppressionsFile" type="msb:StringPropertyType" substitutionGroup="msb:Property">
        <xs:annotation>
            <xs:documentation><!-- _locID_text="CodeAnalysisModuleSuppressionsFile" _locComment="" -->Name of the file, without the path, where Code Analysis project-level suppressions are stored. The default is 'GlobalSuppressions$(DefaultLanguageSourceExtension)'.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="CodeAnalysisOverrideRuleVisibilities" type="msb:boolean" substitutionGroup="msb:Property">
        <xs:annotation>
            <xs:documentation><!-- _locID_text="CodeAnalysisOverrideRuleVisibilities" _locComment="" -->Indicates whether to run all overridable Code Analysis rules against all targets. This will cause specific rules, such as those within the Design and Naming categories, to run against both public and internal APIs, instead of only public APIs. The default is false.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="CodeAnalysisOutputToConsole" type="msb:boolean" substitutionGroup="msb:Property">
        <xs:annotation>
            <xs:documentation><!-- _locID_text="CodeAnalysisOutputToConsole" _locComment="" -->Indicates whether to output Code Analysis warnings and errors to the console. The default is false.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="CodeAnalysisVerbose" type="msb:boolean" substitutionGroup="msb:Property">
        <xs:annotation>
            <xs:documentation><!-- _locID_text="CodeAnalysisVerbose" _locComment="" -->Indicates whether to output verbose Code Analysis diagnostic info to the console. The default is false.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="CodeAnalysisPath" type="msb:StringPropertyType" substitutionGroup="msb:Property">
        <xs:annotation>
            <xs:documentation><!-- _locID_text="CodeAnalysisPath" _locComment="" -->Path to the Code Analysis installation folder. The default is '$(VSINSTALLDIR)\Team Tools\Static Analysis Tools\FxCop'.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="CodeAnalysisPlatformPath" type="msb:StringPropertyType" substitutionGroup="msb:Property">
        <xs:annotation>
            <xs:documentation><!-- _locID_text="CodeAnalysisPlatformPath" _locComment="" -->Path to the .NET Framework folder that contains platform assemblies, such as mscorlib.dll and System.dll. The default is an empty string ('').</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="CodeAnalysisProject" type="msb:StringPropertyType"  substitutionGroup="msb:Property">
        <xs:annotation>
            <xs:documentation><!-- _locID_text="CodeAnalysisProject" _locComment="" -->Path to the Code Analysis project (*.fxcop) to load. The default is an empty string ('').</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="CodeAnalysisQuiet" type="msb:boolean" substitutionGroup="msb:Property">
        <xs:annotation>
            <xs:documentation><!-- _locID_text="CodeAnalysisQuiet" _locComment="" -->Indicates whether to suppress all Code Analysis console output other than errors and warnings. This applies when $(CodeAnalysisOutputToConsole) is true. The default is false.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="CodeAnalysisRuleAssemblies" type="msb:StringPropertyType" substitutionGroup="msb:Property">
        <xs:annotation>
            <xs:documentation><!-- _locID_text="CodeAnalysisRuleAssemblies" _locComment="" -->Semicolon-separated list of paths either to Code Analysis rule assemblies or to folders that contain Code Analysis rule assemblies. The paths are in the form '[+|-][!][file|folder]', where '+' enables all rules in rule assembly, '-' disables all rules in rule assembly, and '!' causes all rules in rule assembly to be treated as errors. For example '+D:\Projects\Rules\NamingRules.dll;+!D:\Projects\Rules\SecurityRules.dll'. The default is '$(CodeAnalysisPath)\Rules'.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="CodeAnalysisRuleDirectories" type="msb:StringPropertyType" substitutionGroup="msb:Property">
         <xs:annotation>
            <xs:documentation><!-- _locID_text="CodeAnalysisRuleDirectories" _locComment="" -->Semicolon-separated list of directories in which to search for rules when resolving a rule set. The default is '$(CodeAnalysisPath)\Rules' unless the CodeAnalysisIgnoreBuiltInRules property is set to true.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="CodeAnalysisRules" type="msb:StringPropertyType" substitutionGroup="msb:Property">
         <xs:annotation>
            <xs:documentation><!-- _locID_text="CodeAnalysisRules" _locComment="" -->Semicolon-separated list of Code Analysis rules. The rules are in the form '[+|-][!]Category#CheckId', where '+' enables the rule, '-' disables the rule, and '!' causes the rule to be treated as an error. For example, '-Microsoft.Naming#CA1700;+!Microsoft.Naming#CA1701'. The default is an empty string ('') which enables all rules.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="CodeAnalysisRuleSet" type="msb:StringPropertyType" substitutionGroup="msb:Property">
         <xs:annotation>
            <xs:documentation><!-- _locID_text="CodeAnalysisRuleSet" _locComment="" -->A .ruleset file which contains a list of rules to run during analysis. The string can be a full path, a path relative to the project file, or a file name. If a file name is specified, the CodeAnalysisRuleSetDirectories property will be searched to find the file. The default is an empty string ('').</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="CodeAnalysisRuleSetDirectories" type="msb:StringPropertyType" substitutionGroup="msb:Property">
         <xs:annotation>
            <xs:documentation><!-- _locID_text="CodeAnalysisRuleSetDirectories" _locComment="" -->Semicolon-separated list of directories in which to search for rule sets. The default is '$(VSINSTALLDIR)\Team Tools\Static Analysis Tools\Rule Sets' unless the CodeAnalysisIgnoreBuiltInRuleSets property is set to true.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="CodeAnalysisSaveMessagesToReport" type="msb:StringPropertyType" substitutionGroup="msb:Property">
        <xs:annotation>
            <xs:documentation><!-- _locID_text="CodeAnalysisSaveMessagesToReport" _locComment="" -->Comma-separated list of the type ('Active', 'Excluded', or 'Absent') of warnings and errors to save to the output report file. The default is 'Active'.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="CodeAnalysisSearchGlobalAssemblyCache" type="msb:boolean" substitutionGroup="msb:Property">
        <xs:annotation>
            <xs:documentation><!-- _locID_text="CodeAnalysisSearchGlobalAssemblyCache" _locComment="" -->Indicates whether Code Analysis should search the Global Assembly Cache (GAC) for missing references that are encountered during analysis. The default is true.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="CodeAnalysisSummary" type="msb:boolean" substitutionGroup="msb:Property">
        <xs:annotation>
            <xs:documentation><!-- _locID_text="CodeAnalysisSummary" _locComment="" -->Indicates whether to output a Code Analysis summary to the console after analysis. The default is false.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="CodeAnalysisTimeout" type="msb:StringPropertyType" substitutionGroup="msb:Property">
        <xs:annotation>
            <xs:documentation><!-- _locID_text="CodeAnalysisTimeout" _locComment="" -->The time, in seconds, that Code Analysis should wait for analysis of a single item to complete before it aborts analysis. Specify 0 to cause Code Analysis to wait indefinitely. The default is 120.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="CodeAnalysisTreatWarningsAsErrors" type="msb:boolean" substitutionGroup="msb:Property">
        <xs:annotation>
            <xs:documentation><!-- _locID_text="CodeAnalysisTreatWarningsAsErrors" _locComment="" -->Indicates whether to treat all Code Analysis warnings as errors. The default is false.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="CodeAnalysisUpdateProject" type="msb:boolean" substitutionGroup="msb:Property">
        <xs:annotation>
            <xs:documentation><!-- _locID_text="CodeAnalysisUpdateProject" _locComment="" -->Indicates whether to update the Code Analysis project (*.fxcop) specified in $(CodeAnalysisProject). This applies when there are changes during analysis. The default is false.</xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:element name="CodeAnalysisUseTypeNameInSuppression" type="msb:boolean" substitutionGroup="msb:Property">
        <xs:annotation>
            <xs:documentation><!-- _locID_text="CodeAnalysisUseTypeNameInSuppression" _locComment="" -->Indicates whether to include the name of the rule when Code Analysis emits a suppression. The default is true.</xs:documentation>
        </xs:annotation>