有条件地包括NuGet包

时间:2016-05-10 07:26:14

标签: visual-studio nuget xamarin-studio

有没有人在构建中有条件地包含NuGet包的经验?理想情况下,如果可以基于构建配置完成这样做会很好,例如,包A包含在Debug构建中,但包B在Release版本中使用。

这可能吗?

1 个答案:

答案 0 :(得分:1)

您可以编辑.csproj文件,并在ItemGroup部分中包括以下内容,以有条件地包括所有程序包。

<ItemGroup Condition="'$(Configuration)'=='Debug'">
   //Move any package reference here that will only be available in debug mode 
   <PackageReference Include="PackageA" Version="1.0.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(Configuration)'=='Release'">
   //Move any package reference here that will only be available in release mode 
   <PackageReference Include="PackageB" Version="1.0.0.0" />
</ItemGroup>

希望这会有所帮助。

相关问题