2012-06-14 111 views
1

我正在嘗試使用cmd或jenkins構建作業來使用msbuild運行構建文件。MsBuild和FxCop問題

項目的結構是

project structure

演示是在這裏:www.saramgsilva.com/wp7/sarasilvademo.rar

現在我有3點diferents的方式來運行的FxCop,但我在所有的問題。

1)在CMD去根文件,然後運行

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe .\SaraSilva.WP7.build /target:FxCop 

此示出了錯誤:用代碼出口128

2)在CMD去根文件和然後運行

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe .\SaraSilva.WP7C.build /target:FxCop 

這不會創建構建文件\ FxCop \ FxCopAnalysis.xml文件。

3)在cmd中去根文件,然後運行

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe .\SaraSilva.WP7.build /target:TestWithCoverage 

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 

結果是:

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.

我不知道是什麼要做:(

回答

6

答案是下面的開關添加到命令行來告訴FxCop的搜索GAC程序集:

/gac 
+0

我收到錯誤消息 注意:找不到一個或多個引用的程序集。使用'/ directory'開關指定其他裝配參考搜索路徑。 這個開關/ gac修復了這個問題。 – mbenegas

2

雖然我使用的FxCop 10.0你把錯誤代碼是similiar:

NOTE: One or more referenced assemblies could not be found. Use the '/directory' switch to specify additional assembly reference search paths.

因此,對於我來說,我修改FxCopCmd.exe.config文件,並改變AssemblyReferenceResolveMode從強名稱StrongNameIgnoringVersion

這是爲了確保它不會試圖找到引用的程序集

的特定版本

也確保在Visual Studio中的DLL性質是有複製本地=真