Search code examples
visual-studiotfsmsbuildcode-analysis

TFS Build failing because of Code Analysis settings


I've turned on Code Analysis for all of my projects, and have verified code analysis is on for each configuration (Debug, Release, QA, etc). My local builds are of course fine, my TFS builds are failing still.

Here is the failed output XML file in the drop location for my builds:

<?xml version="1.0" encoding="utf-8"?>
<Tests xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <BuildConfigurationSettings name="Debug" ProjectName="MyProject" Platform="AnyCPU">
    <Test>
      <MSBuildSchemaName>CodeAnalysisRuleSet</MSBuildSchemaName>
      <ExpectedValue>MinimumRecommendedRules.ruleset</ExpectedValue>
      <ActualValue />
      <Verify>true</Verify>
      <TestExecuted>true</TestExecuted>
      <IsEqual>false</IsEqual>
    </Test>
  </BuildConfigurationSettings>
  <BuildConfigurationSettings name="Release" ProjectName="MyProject" Platform="AnyCPU">
    <Test>
      <MSBuildSchemaName>CodeAnalysisRuleSet</MSBuildSchemaName>
      <ExpectedValue>MinimumRecommendedRules.ruleset</ExpectedValue>
      <ActualValue />
      <Verify>true</Verify>
      <TestExecuted>true</TestExecuted>
      <IsEqual>false</IsEqual>
    </Test>
  </BuildConfigurationSettings>
</Tests>

Solution

  • For some reason, even though Code Analysis was turned on in the 'Properties' for the failing projects, the changes were not being reflected in the .csproj file. After hand-editing the .csproj file to include the minimum ruleset, everything was working fine:

    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>