UWP 项目中的条件包引用 [英] Conditional package reference in UWP project
本文介绍了UWP 项目中的条件包引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用一个 NuGet 包仅用于调试配置.我发现如果我有一个针对 Creators Update (15063) 的 UWP 项目,请在 Visual Studio 2017 中执行此操作.
I would like to use one NuGet package just for Debug configuration. I found possibility to do it in Visual Studio 2017 if I have a UWP project targeting Creators Update (15063).
<PackageReference Include="Newtonsoft.json" Version="9.0.1" Condition="'$(Configuration)' == 'Debug'" />
但是该包仍然存在,用于发布配置.
But the package is still there also for Release configuration.
推荐答案
<Choose>
<When Condition=" '$(Configuration)'=='Debug' ">
<ItemGroup>
<PackageReference Include="Newtonsoft.json" Version="9.0.1" />
</ItemGroup>
</When>
</Choose>
PackageReference 必须在一个 ItemGroup 中才能正常工作.
The PackageReference has to be in an ItemGroup than it works.
这篇关于UWP 项目中的条件包引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文