Defaulting Package Management to PackageReference

一笑奈何 提交于 2019-12-06 07:29:19

问题


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:


回答1:


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.



来源:https://stackoverflow.com/questions/49160858/defaulting-package-management-to-packagereference

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!