MSBuild ItemGroup条件项目引用



我正试图根据ItemGroup条件中的值包含项目参考

这就是我尝试过的。使用BeforeTargets Compile,它确实识别了该项目,但它不允许我构建该项目。

<Target Name="ErpSystemToUse" BeforeTargets="Compile">
<ReadLinesFromFile File="$(MSBuildProjectDirectory)....PresentationNop.WebApp_DataerpSystemToUse.txt">
<Output TaskParameter="Lines" ItemName="ValueTextFile" />
</ReadLinesFromFile>
<Message Text="@(ValueTextFile)" Importance="high" />
<ItemGroup Condition="'@(ValueTextFile)' == 'Twinfield'">
<ProjectReference Include="....Dimerce.TwinfieldDimerce.Plugin.Misc.TwinfieldDimerce.Plugin.Misc.Twinfield.csproj" />
</ItemGroup>
</Target>

我努力实现的目标可能实现吗?

我有一个项目,我必须检查System.Reflection.Emit的输出。仅当定义了适当的常数时,才决定包含包引用

主要区别在于目标在CollectPackageReferences之前执行。尝试更改BeforeTargets

同时使用InputsOutputs来减少的构建时间

<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>

最新更新