2011-12-15 8 views
2

私はMSBuildの新機能で、操作方法を理解するのに少し時間がかかります。MSBuildのFxCopとCA0060の例外を無効にする

私はビルドサーバーでビルドするときに自動的に実行されるようにプロジェクトにFxCopを統合しようとしています。

現在、ビルド時に呼び出すビルドにカスタムタスクを追加する方法があります。だから私は、これまでに以下のように作成しました:私はこの>msbuild XXXX.csproj /t:ExecuteFxCopを実行すると

<Target Name="ExecuteFxCop"> 
    <ItemGroup> 
    <Files Include="bin\XXXX.dll" /> 
    </ItemGroup> 
    <!-- Call the task using a collection of files and all default rules --> 
    <MSBuild.ExtensionPack.CodeQuality.FxCop 
    TaskAction="Analyse" 
    Files="@(Files)" 
    SearchGac="True" 
    OutputFile="FxCopReport.xml"> 
    </MSBuild.ExtensionPack.CodeQuality.FxCop> 
</Target> 

は、しかし、それは私が間接的に参照assemblysから例外に絞ってきたエラー512で失敗します。

<Exception Keyword="CA0060" Kind="Engine" TreatAsWarning="True"> 
    <Type>Microsoft.FxCop.Sdk.FxCopException</Type> 
    <ExceptionMessage>The indirectly-referenced Silverlight assembly 'System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' could not be found. This assembly is not required for analysis, however, analysis results could be incomplete. Silverlight reference assemblies should be specified with the '/reference' switch. This assembly was referenced by: XXX\bin\ESRI.ArcGIS.Client.dll.</ExceptionMessage> 
</Exception> 

しかし、私この参照を追加できません。このリファレンスを参照するようにビルドを行う方法がありますか、できればエラーを完全に無効にするのが望ましいですか? http://social.msdn.microsoft.com/Forums/en-US/vstscode/thread/c6780439-bc04-459e-80c3-d1712b2f5456/それは

答えて

2

はここに回避策を試してみては動作しません:私はしてみてくださいでした

http://geekswithblogs.net/blachniet/archive/2011/07/12/avoiding-fxcop-warning-ca0060.aspx

編集

例えばは、FxCopののMSBuildタスクを使用して、のContinueOnErrorを設定し、次のようにExitCodeを確認します。

<Target Name="ExecuteFxCop"> 
    <ItemGroup> 
    <Files Include="bin\XXXX.dll" /> 
    </ItemGroup> 
    <!-- Call the task using a collection of files and all default rules --> 
    <MSBuild.ExtensionPack.CodeQuality.FxCop 
    TaskAction="Analyse" 
    Files="@(Files)" 
    SearchGac="True" 
    OutputFile="FxCopReport.xml" 
    ContinueOnError="WarnAndContinue"> 
    <Output TaskParameter="ExitCode" PropertyName="ExitCode"/> 
    </MSBuild.ExtensionPack.CodeQuality.FxCop> 

    <Error Condition="$(ExitCode) != 512" Text="FxCop failed with exit code: $(ExitCode)"/> 

</Target> 

PSあなたはまだ解決策を探しているが、何を、通常は私の作品は、基本的にアセンブリのためにその追加のディレクトリ内で検索するFxCopのを伝え

fxcop cmd-option /d:{dir-of-random-assemblies} 

を追加している場合

+0

ありがとうございました。投稿のビルド手順でFxCopを実行しないと、これはうまくいきませんが、FxCopを実行してエラーを取り除く必要があるかもしれません。我々は見るであろう。 – Firedragon

+0

権利。しばらくして、特定のエラーコードを無視するための新しい機能要求を作成することができます。http://msbuildextensionpack.codeplex.com/workitem/list/basic –

+0

解決策はありましたか? – Alex

関連する問題