我正在尝试根据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>我想要实现的目标有可能实现吗?
发布于 2021-06-10 09:50:32
我有一个项目,我必须检查System.Reflection.Emit的输出。决定仅在定义了适当的常量时才包含包引用
主要不同之处在于,目标在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>https://stackoverflow.com/questions/67902648
复制相似问题