Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RunCodeAnalysis=true not working in command prompt (MSBuild)

I'm trying to get msbuild to output code analysis info like it does in VS. I have a configuration for my project called "CodeAnalysis" in VS that is set up to run code analysis on build (with the minimum ruleset). Anyway this is working fine in VS, but when I run msbuild from the command line it only shows the basic build warnings and it doesn't run code analysis at all. Anyone know why this is happening?

Configuration in project file:

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'CodeAnalysis|AnyCPU'">
<OutputPath>bin\</OutputPath>
<CodeAnalysisRuleSet>C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\Rule Sets\MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>true</RunCodeAnalysis>

Command line:

msbuild Solution.sln /p:Configuration=CodeAnalysis /t:Rebuild

I also tried:

msbuild Solution.sln /p:RunCodeAnalysis=true /t:Rebuild
like image 443
mike d Avatar asked Oct 18 '11 13:10

mike d


2 Answers

By default, MSBuild uses the value configured in the project file, but you can override it on the msbuild command-line using the argument

/p:RunCodeAnalysis=true

to always run code analysis. Vice versa, use

/p:RunCodeAnalysis=false

to disable code analysis.

See also:

  • Disable Code Analysis for Some Projects using MSBuild
like image 140
Keith Avatar answered Oct 15 '22 14:10

Keith


You need to have Visual Studio installed on the machine. There are many scripts that are included via csproj line:

As you have VS (of proper edition) installed it will include FxCop targets file and will start Code Analysis for you.

like image 32
Eugene Petrenko Avatar answered Oct 15 '22 14:10

Eugene Petrenko