将包管理默认为 PackageReference [英] Defaulting Package Management to PackageReference

查看:98
本文介绍了将包管理默认为 PackageReference的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Nuget.Config 中是否有任何方法可以将包管理选项默认为PackageReference"?我将假设没有,因为我没有看到它

解决方案

在 Visual Studio 2017 中,您可以在 NuGet.Config 文件中定义设置.

<预><代码><配置><包管理><add key="format" value="1"/><add key="disabled" value="False"/></packageManagement></配置>

格式值可以是 1 或 0.PackageReference = 1.Packages.config = 0.

禁用标志有点令人困惑,至少对我而言.将其设置为 False 似乎禁用了对话框提示,该提示要求您选择在第一次安装包时使用哪种格式.查看代码,此禁用设置指的是 DoNotShowPackageManagementSelectionKey,然后在 PackageManagementFormat.Enabled 属性中返回禁用值.这对我来说似乎是错误的方式.我试图将禁用设置为 True 并想知道为什么显示对话框.

如果您在目录中拥有与解决方案处于同一级别或更高级别的 NuGet.Config 文件,则应选择并使用该文件.

Is there any way in the Nuget.Config to default the Package Management option to "PackageReference"? I'm going to assume no since I didn't see it here but I thought I'd ask.

I'm looking to default this on all developer machines for a certain repository and I was hoping I could change this in the Nuget.Config file that is stored in source control.

This is what I'm talking about:

解决方案

In Visual Studio 2017 you can define the settings in a NuGet.Config file.

<configuration>
  <packageManagement>
    <add key="format" value="1" />
    <add key="disabled" value="False" />
  </packageManagement>
</configuration>

The format value can be 1 or 0. PackageReference = 1. Packages.config = 0.

The disabled flag is a bit confusing, at least to me. Setting it to False seems to disable the dialog prompt that asks you to choose which format to use on first package install. Looking at the code this disabled setting refers to a DoNotShowPackageManagementSelectionKey and the disabled value is then returned in the PackageManagementFormat.Enabled property. Which seems the wrong way around to me. I was trying disabled set to True and wondering why the dialog was being displayed.

If you have that NuGet.Config file at the same level as the solution or higher in the directory it should be picked up and used.

这篇关于将包管理默认为 PackageReference的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆