Here is a sample msbuild script which i have written. Assuming New is the default target.

<Target Name="New" DependsOnTargets="Clean">
    <MSBuild Projects=".\folder1\sample.csproj" />
</Target>
<Target Name="Clean" >
    <ItemGroup>
        <BinFiles Include=".\**\bin\**\*.*"/>
    </ItemGroup>
    <Delete Files="@(BinFiles)"/>
</Target>

On my project I have set warnings as errors and supressed quite a few warnings using System.Diagnostics.CodeAnalysis.SuppressMessage.While this works well in visualstudio...I obtain all the errors coming up while i run the msbuild file.

I have checked the net and found that CODE_ANALYSIS is supposed to be added to the conditional compilation symbols and I have done that (under project properties/build of all projects which sample.csproj is using) but I still face the same issue.

What can i be doing wrong?

Below is the log statement taken just before i get the errors.

RunCodeAnalysis:   
Running Code Analysis...   
c:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static AnalysisTools\FxCop\FxCopCmd.exe <lot of custom parameters references>
link|edit|flag

75% accept rate
Sounds like you are saying that CODE_ANALYSIS is defined when you build from the IDE, but not when you build from the command line. One way that this can happen is if the Platform|Configuration combination you are building is different between the two. Is this possibly what you are seeing? – Spider M9 8 hours ago
@Spider M9: Maybe...but i have defined the CODE_ANALYSIS constant on every config listed in the projectfile.I have even defined it in all the dependent projects. I am still receiving this error.Fx cop is totally ignoring all supress messages even now! – Mulki 2 hours ago

1 Answer

Check out if your .csproj files actually contain CODE_ANALYSIS constant:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    ...
    <DefineConstants>DEBUG;TRACE;CODE_ANALYSIS</DefineConstants>
    <RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
link|edit|flag
the proj file doesnt have a CODE_ANALYSIS constant. But it comes up when i open the project properties in GUI – Mulki 4 hours ago
OK...added it to the project file. I am still receiving the errors. I have added CODE_ANALYSIS to all configs of the project and its dependent project where this warning is being thrown... – Mulki 3 hours ago

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.