[英]MSBuild ItemGroup Condition Project Reference
I'm trying to include a Project Reference based on a value in the ItemGroup Condition我正在尝试根据 ItemGroup 条件中的值包含项目参考
This is what I have tried.这是我尝试过的。 With BeforeTargets Compile it does recognize the project but it won't let me build the project.
使用 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>
Is what I am trying to achieve possible?我想要实现的目标是可能的吗?
I have a project where I had to inspect output of System.Reflection.Emit
.我有一个项目,我必须检查
System.Reflection.Emit
的 output 。 Decided to include package reference only when appropriate constant is defined仅在定义了适当的常量时才决定包含 package 参考
Main difference is that target executes before CollectPackageReferences
.主要区别在于 target 在
CollectPackageReferences
之前执行。 Try to change BeforeTargets
.尝试更改
BeforeTargets
。
Also use Inputs
and Outputs
to reduce build time还使用
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.