sebingel
sebingel

Reputation: 470

Package destination of restore of .net-core projects is always global package directory

We have a solution in which some projects are .net-core projects and some are "normal" .net 4.6.1 projects. On solution level we have a NuGet.config-File which sets the repositoryPath:

<configuration>
  <config>
    <add key="repositoryPath" value="packages" />
  </config>
</configuration>

The packages listed in the projects packages.config-Files are getting downloaded into the path specified in Nuget.config -> repositoryPath but the packages specified in the .net-core Project files (via PackageReference) are all downloaded into the global package directory in C:\Users\USERNAME\.nuget\packages.

It doesn't matter if i use Visual Studio 2017 or do it manually via nuget.exe. The .net-core projects just ignore the NuGet.config.

What are we doing wrong here?

Upvotes: 3

Views: 2775

Answers (2)

sebingel
sebingel

Reputation: 470

Okay. Got it. Adding the following tag to the .csproj file does the trick:

    <PropertyGroup>
      ...
      <RestorePackagesPath>packages</RestorePackagesPath>
    </PropertyGroup>

Source: https://github.com/NuGet/Home/wiki/%5BSpec%5D-NuGet-settings-in-MSBuild

Upvotes: 6

Justin Emgarten
Justin Emgarten

Reputation: 2368

respositoryPath is used for packages.config projects

globalPackagesFolder is used for PackageReference projects

Since packages.config and PackageReference use different folder formats these project types cannot use the same folder for packages, which is why there are two different config settings.

Upvotes: 3

Related Questions