[英]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.