![](/img/trans.png)
[英]C# - MSBuild reference - Copy to CopyToOutputDirectory all items of <itemGroup>
[英]MSBuild ItemGroup Condition Project Reference
我正在尝试根据 ItemGroup 条件中的值包含项目参考
这是我尝试过的。 使用 BeforeTargets Compile 它确实可以识别该项目,但它不会让我构建该项目。
<Target Name="ErpSystemToUse" BeforeTargets="Compile">
<ReadLinesFromFile File="$(MSBuildProjectDirectory)\..\..\Presentation\Nop.Web\App_Data\erpSystemToUse.txt">
<Output TaskParameter="Lines" ItemName="ValueTextFile" />
</ReadLinesFromFile>
<Message Text="@(ValueTextFile)" Importance="high" />
<ItemGroup Condition="'@(ValueTextFile)' == 'Twinfield'">
<ProjectReference Include="..\..\Dimerce.Twinfield\Dimerce.Plugin.Misc.Twinfield\Dimerce.Plugin.Misc.Twinfield.csproj" />
</ItemGroup>
</Target>
我想要实现的目标是可能的吗?
我有一个项目,我必须检查System.Reflection.Emit
的 output 。 仅在定义了适当的常量时才决定包含 package 参考
主要区别在于 target 在CollectPackageReferences
之前执行。 尝试更改BeforeTargets
。
还使用Inputs
和Outputs
来减少构建时间
<Target Name="IncludeIlPackReference"
Inputs="$(DefineConstants)" Outputs="@(PackageReference)"
BeforeTargets="CollectPackageReferences"
Condition="$(DefineConstants.Contains('TRACE_GENERATED_IL'))">
<ItemGroup>
<PackageReference Include="Lokad.ILPack" Version="0.1.6" />
</ItemGroup>
</Target>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.