.net核心项目的还原包目的地始终是全局包目录 [英] Package destination of restore of .net-core projects is always global package directory
问题描述
我们有一个解决方案,其中一些项目是.net核心项目,而有些则是常规 .net 4.6.1项目。
在解决方案级别,我们有一个NuGet.config-File来设置repositoryPath:
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>
项目packages.config-Files中列出的软件包将下载到Nuget中指定的路径中。 config-> repositoryPath,但在.net-core Project文件中指定的软件包(通过PackageReference)都下载到C:\Users\USERNAME\.nuget\packages中的全局软件包目录中。
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.
我使用Visual Studio 2017还是通过nuget.exe手动进行都没关系。
.net核心项目只是忽略NuGet.config。
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?
推荐答案
好的。得到它了。将以下标签添加到.csproj文件即可:
Okay. Got it. Adding the following tag to the .csproj file does the trick:
<PropertyGroup>
...
<RestorePackagesPath>packages</RestorePackagesPath>
</PropertyGroup>
来源: https://github.com/NuGet/Home/wiki/%5BSpec%5D-NuGet-settings-in-MSBuild
这篇关于.net核心项目的还原包目的地始终是全局包目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!