问题
I'm trying to make a build file to run with msbuild using cmd or jenkins build job.
The structure of the project is

the demo is here: www.saramgsilva.com/wp7/sarasilvademo.rar
Now i have 3 diferents ways to run fxcop, but i have problems in all.
1) In cmd go to the root file and then run
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe .\SaraSilva.WP7.build /target:FxCop
this show a error: exit with code 128
2) In cmd go to the root file and then run
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe .\SaraSilva.WP7C.build /target:FxCop
this doesn't create the buildartifacts\FxCop\FxCopAnalysis.xml file.
3) In cmd go to the root file and then run
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe .\SaraSilva.WP7.build /target:TestWithCoverage
and
C:\SaraSilvaDemo\tools\FxCop-1.36\FxCopCmd.exe /file:C:\SaraSilvaDemo\buildartifacts /directory:C:\SaraSilvaDemo\buildartifacts\ /rule:C:\SaraSilvaDemo\tools\FxCop-1.36\Rules /out:C:\SaraSilvaDemo\buildartifacts\fxcop-result.xml
the result is:
Microsoft (R) FxCop Command-Line Tool, Version 1.36 (9.0.30729.1) Copyright (C) 2007 Microsoft Corporation. All rights reserved.
Loaded DesignRules.dll... Loaded GlobalizationRules.dll... Loaded InteroperabilityRules.dll... Loaded MobilityRules.dll... Loaded NamingRules.dll... Loaded PerformanceRules.dll... Loaded PortabilityRules.dll... Loaded SecurityRules.dll... Loaded UsageRules.dll... Could not load Cimbalino.Phone.Toolkit.dll. Could not load GalaSoft.MvvmLight.Extras.WP71.dll. Could not load GalaSoft.MvvmLight.WP71.dll. Could not load Microsoft.Phone.Controls.dll. Could not load Microsoft.Practices.ServiceLocation.dll. Could not load mscorlib.Extensions.dll. Could not load NLog.dll. Loaded nunit.framework.dll... Loaded SaraSilva.WP7.AllTests.dll... Could not load SaraSilva.WP7.App.dll. Could not load SaraSilva.WP7.Model.dll. Could not load SaraSilva.WP7.SampleData.dll. Could not load SaraSilva.WP7.SchedTask.dll. Could not load SaraSilva.WP7.Service.dll. Loaded System.Core.dll... Could not load System.dll. Could not load System.Windows.Browser.dll. Loaded System.Windows.dll... Could not load System.Windows.Interactivity.dll. Could not load System.Xml.dll. Could not load TombstoneHelper.dll. Initializing Introspection engine... Could not resolve reference to System.Net. Analysis Complete.
NOTE: One or more referenced assemblies could not be found. Use the '/directory' switch to specify additional assembly reference search paths.
- Analysis was not performed; at least one valid rules assembly and one valid target file must be specified.
- 2 total analysis engine exceptions. Writing report to C:\SaraSilvaDemo\buildartifacts\fxcop-result.xml... Done.
I don´t know what to do :(
回答1:
The answer is to add the following switch to the command line to tell FxCop to search the GAC for assemblies:
/gac
回答2:
Although I'm using FXCop 10.0 the error code you put are similiar:
NOTE: One or more referenced assemblies could not be found. Use the '/directory' switch to specify additional assembly reference search paths.
hence, for my case I modified FxCopCmd.exe.config file and change AssemblyReferenceResolveMode from StrongName to StrongNameIgnoringVersion
This is to ensure that it doesn't trying to find specific version of referenced assemblies
also make sure in Visual Studio the dll properties is having Copy Local = True
来源:https://stackoverflow.com/questions/11034922/msbuild-and-fxcop-problems