使用MSBuild将输出项传递给单独的目标
我正在创建一个构建脚本,其中输出MSBuild的targetOutput,然后希望在单独的目标中调用FXCop,并在TargetAssembly中使用这些输出使用MSBuild将输出项传递给单独的目标,msbuild,fxcop,msbuild-4.0,msbuildcommunitytasks,Msbuild,Fxcop,Msbuild 4.0,Msbuildcommunitytasks,我正在创建一个构建脚本,其中输出MSBuild的targetOutput,然后希望在单独的目标中调用FXCop,并在TargetAssembly中使用这些输出 <Target Name="Build"> <MSBuild Projects="@(Projects)" Properties="Platform=$(Platform);Configuration=$(Configuration);" Targets="Bu
<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的消息为空,而如果我将其放入构建目标中,它将填充
如何传递/引用此值?赛义德·易卜拉欣·哈希米(Inside MSBuild book的合著者)的一篇文章描述了您在2005年遇到的问题。实际上,CallTarget任务的行为很奇怪。我不确定这是错误还是设计的行为,但在MSBuild 4.0中行为仍然相同
作为一种解决方法,请使用常规的MSBuild机制,在MSBuild中使用属性DependsOnTargets、BeforeTargets或AfterTargets设置目标的执行顺序 我能想出这个 实际上,在MSBuild步骤之后,我创建了一个ItemGroup,然后在调用目标中引用它
<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>