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

谁说我不能喝 提交于 2019-12-23 04:32:26

问题


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

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