使在 MSBuild 目标中创建的 ItemGroup 可用于调用目标

问题描述 投票:0回答:1
msbuild target
1个回答
5
投票

有两点需要注意。首先,CreateItem 任务基本上已经过时了。只需在目标中声明一个 ItemGroup 即可使其更具可读性。其次,由于 MSBuild 发布项目的方式,您需要使 CreateTestList 目标作为依赖项运行,而不是与 CallTarget 一起运行,后者在大多数情况下用处有限。所以,

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

<Target Name="CreateTestList">     
   <ItemGroup>
      <TestAssembly Include="**\bin\$(Configuration)\*Tests.dll">
   </ItemGroup>
   <Message
      ...
</Target>
© www.soinside.com 2019 - 2024. All rights reserved.