문제

If I have the following targets in an MSBuild file:

<Target Name="Temp">
   <CallTarget Targets="CreateTestList" />
   <Message Text="TestList: -- @(TestAssembly) -- " />
   <Message Text="Testing &quot;%(TestAssembly.Identity)&quot;" />
</Target>   

<Target Name="CreateTestList">
     <CreateItem Include="**\bin\$(Configuration)\*Tests.dll">
          <Output TaskParameter="Include" ItemName="TestAssembly" />
     </CreateItem>
     <Message Text="TestList: -- @(TestAssembly) -- " />
     <Message Text="Testing &quot;%(TestAssembly.Identity)&quot;" />
</Target>

How do I make the Message statements in my Temp target print out the items that the CreateTestList target put into the @(TestAssemblyList) ItemGroup?

도움이 되었습니까?

해결책

Two things to note. First, the CreateItem task is essentially obsolete. Make it more readable by just declaring an ItemGroup inside your target. Second, due to how MSBuild publishes items, you need to make the CreateTestList target run as a dependency, not with CallTarget, which in most cases has limited usefulness. So,

<Target Name="Temp" DependsOnTargets="CreateTestList">
   <Message
      ...
</Target>

<Target Name="CreateTestList">     
   <ItemGroup>
      <TestAssembly Include="**\bin\$(Configuration)\*Tests.dll">
   </ItemGroup>
   <Message
      ...
</Target>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top