问题
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?
回答1:
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
回答2:
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.
来源:https://stackoverflow.com/questions/47311192/package-destination-of-restore-of-net-core-projects-is-always-global-package-di