I'm using a combination of Microsoft Code Analysis and MSBuild for my build, the gist is that I want my .proj file to break on compilatin
using MSBuild.exe; when Code Analysis starts to throw errors.
I don't want to set the attributes TreatErrorAsWarnings on the individual projects in Visual Studio. I've created a MSBuild script to
build my solution containing a few .csproj files. To achieve my goal I thought it would be as easy as setting the property <CodeAnalysisTreatWarningsAsErrors> to true. However this is not the case. Please can anyone help me?
<Project Toolversion="3.5" DefaultTargets="Test" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<PropertyGroup>
<SolutionFileName>Test.sln</SolutionFileName>
<BuildDirectory>$(MSBuildProjectDirectory)</BuildDirectory>
<RunCodeAnalysis>Always</RunCodeAnalysis>
<CodeAnalysis>
<TreatWarningsAsErrors>$(CodeAnalysisTreatWarningsAsErrors)</TreatWarningsAsErrors>
</CodeAnalysis>
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
</PropertyGroup>
<Target Name="Clean">
</Target>
<Target Name="Build">
<MSBuild Projects="$(SolutionFileName)" Targets="Clean;Build" ContinueOnError ="false" >
<Output TaskParameter="TargetOutputs" ItemName="Assemblies" />
</MSBuild>
</Target>
<Target Name="InstallDatabase" DependsOnTargets="Build">
<Exec Command ="$(BuildDirectory)\Database\installdatabase.cmd" WorkingDirectory="$(BuildDirectory)\Database" ContinueOnError ="false"/>
</Target>
<Target Name="Test" DependsOnTargets="InstallDatabase" >
<Exec Command='"C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe" /testmetadata:"$(BuildDirectory)\Test.vsmdi"' ContinueOnError ="true" />
<ConvertToAbsolutePath Paths="$(Source_Dir)\TestResults\TestResults.trx">
<Output TaskParameter="AbsolutePaths" PropertyName="Source_Dir_Abs"/>
</ConvertToAbsolutePath>
<Message Text="##teamcity[importData type='mstest' path='$(Source_Dir_Abs)']"/>
</Target>
</Project>