Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Defaulting Package Management to PackageReference

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:

enter image description here

like image 574
Cole W Avatar asked Jan 28 '23 13:01

Cole W


1 Answers

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.

like image 144
Matt Ward Avatar answered Apr 29 '23 04:04

Matt Ward