Code Analysis fails when building with FinalBuilder

1.9k Views Asked by At

Update 3 I have now discovered that it appears that an old version of FxCop is invoked when FinalBuilder is calling MSBUILD. Using the command line, when running with the VS2010 version of FxCop everything works fine, but when I use the same command for VS2008 I get the error message Switch /reference is an unknown switch.

I had a Visual Studio 2008 solution which was built using FinalBuilder 6.

I have now converted the solution to Visual Studio 2010 and upgraded to FinalBuilder 7. The solution builds fine using static code analysis from within Visual Studio, however the build fails when running in FinalBuilder 7, with the following error:

Running Code Analysis...

Switch '/reference' is an unknown switch.

MSBUILD : error : CA0059 : Invalid settings passed to CodeAnalysis task. See output window for details.

What is causing this, and how can I resolve this issue? I can't find anywhere what the /reference switch means, or where it is set. Since it works in Visual Studio I am thinking it might have something to do with how FinalBuilder calls upon MSBUILD, but I'm guessing here.

Any ideas would be much appreciated.

Update: The code analysis settings is located in a .ruleset file which is part of the solution items, and referenced in the .csproj like this:

<RunCodeAnalysis>true</RunCodeAnalysis>
<CodeAnalysisRules>
</CodeAnalysisRules>
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisRuleSet>..\myproduct.ruleset</CodeAnalysisRuleSet>

Update 2: When running the build command that FinalBuilder is using, from the command line, everything works. I noticed that FxCop is called with the following paramters when calling it from the command line:

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /t:Rebuild /nr:false /p:Configuration="Release";Platform="Any CPU";TargetFramework="v2.0" /v:normal /m "C:\makempm\5.0.0.0\myproductTool.sln"

Which in turn calls upon FxCopCmd.exe like this:

C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\FxCopCmd.exe  
/outputCulture:1033 
/out:"bin\Release\myproduct.exe.CodeAnalysisLog.xml" 
file:"bin\Release\myproduct.exe" /reference:"C:\makempm\5.0.0.0\mpCommon\bin\Release\mpCommon.dll" 
/reference:"C:\makempm\5.0.0.0\mpConfiguration\bin\Release\mpConfiguration.dll"
/reference:"C:\makempm\5.0.0.0\mpDownload\bin\Release\mpDownload.dll" 
/reference:"C:\makempm\5.0.0.0\mpStatus\bin\Release\mpStatus.dll" 
/reference:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll" 
/reference:"c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" 
/reference:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll" 
/reference:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Deployment.dll" 
/reference:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Design.dll" 
/reference:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll" 
/reference:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll" 
/reference:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll" 
/reference:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll" 
/directory:"C:\makempm\5.0.0.0\mpConfiguration\bin\Release" 
/directory:"C:\makempm\5.0.0.0\mpDownload\bin\Release" 
/directory:"c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5" 
/directory:"c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727" 
/directory:"C:\makempm\5.0.0.0\mpStatus\bin\Release" 
/directory:"C:\makempm\5.0.0.0\mpCommon\bin\Release" 
/ruleSet:"=C:\makempm\5.0.0.0\myproduct\..\myproduct.ruleset" 
/rulesetdirectory:"C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets" 
/rule:"-C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules" 
/searchgac 
/ignoreinvalidtargets 
/forceoutput 
/successfile 
/ignoregeneratedcode 
/saveMessagesToReport:Active 
/targetframeworkversion:v3.5 
/timeout:120

And everything is fine:

Code Analysis Complete -- 0 error(s), 0 warning(s)

0

There are 0 best solutions below