2012-02-13 4 views
0

私はMSBuildのTargetOutputsを出力してから、別のターゲットでFXCopを呼び出し、TargetAssembliesでこれらの出力を使用するビルドスクリプトを作成しています。私はこれを実行すると出力項目をMSBuildで別のターゲットに渡す

<Target Name="Build"> 
    <MSBuild Projects="@(Projects)" 
      Properties="Platform=$(Platform);Configuration=$(Configuration);" 
      Targets="Build" 
      ContinueOnError="false"> 
     <Output TaskParameter="TargetOutputs" ItemName="TargetDLLs"/> 
    </MSBuild> 
    <CallTarget Targets="FxCopReport" /> 
</Target> 

<Target Name="FxCopyReport"> 
    <Message Text="FXCop assemblies to test: @(TargetDLLs)" /> 
    <FxCop 
     ToolPath="$(FXCopToolPath)" 
     RuleLibraries="@(FxCopRuleAssemblies)" 
     AnalysisReportFileName="FXCopReport.html" 
     TargetAssemblies="@(TargetDLLs)" 
     OutputXslFileName="$(FXCopToolPath)\Xml\FxCopReport.xsl" 
     ApplyOutXsl="True" 
     FailOnError="False" /> 
</Target> 

、FxCopyReport目標に、空でTargetDLLsのメッセージは、私がビルドターゲットでこれを入れた場合のに対し、それが移入されます。

この値を渡す/参照するにはどうすればよいですか?

答えて

0

Sayed Ibrahim Hashimi(Inside MSBuild書籍の共著者)のblog postがあります。これは2005年に起きた問題を説明しています。本質的にCallTargetタスクは奇妙な動作をしています。私はそれがバグか設計された動作かどうかは分かりませんが、MSBuild 4.0では動作は変わりません。

回避策として、MSBuildのターゲットの実行順序を、DependsOnTargets、BeforeTargetsまたはAfterTargets属性を使用して設定する通常のMSBuildメカニズムを使用します。

0

私はこれを理解することができました。

MSBuildのステップの後で、私はItemGroupを作成しました。これをItemTargetという呼出し先で参照しました。

<Target Name="Build"> 
    <Message Text="Building Solution Projects: %(Projects.FullPath)" /> 
    <MSBuild Projects="@(Projects)" 
      Properties="Platform=$(Platform);Configuration=$(Configuration);" 
      Targets="Build" 
      ContinueOnError="false"> 
     <Output TaskParameter="TargetOutputs" ItemName="TargetDllOutputs"/> 
    </MSBuild> 
    <ItemGroup> 
     <TestAssemblies Include="@(TargetDllOutputs)" /> 
    </ItemGroup> 
    </Target> 

    <Target Name="FXCopReport"> 
    <Message Text="FXCop assemblies to test: @(TestAssemblies)" /> 
    <FxCop 
     ToolPath="$(FXCopToolPath)" 
     RuleLibraries="@(FxCopRuleAssemblies)" 
     AnalysisReportFileName="$(BuildPath)\$(FxCopReportFile)" 
     TargetAssemblies="@(TestAssemblies)" 
     OutputXslFileName="$(FXCopToolPath)\Xml\FxCopReport.xsl" 
     Rules="$(FxCopExcludeRules)" 
     ApplyOutXsl="True" 
     FailOnError="True" /> 
    <Message Text="##teamcity[importData id='FxCop' file='$(BuildPath)\$(FxCopReportFile)']" Condition="'$(TEAMCITY_BUILD_PROPERTIES_FILE)' != ''" /> 
    </Target> 
関連する問題