.net-core 项目还原的包目标始终是全局包目录 [英] Package destination of restore of .net-core projects is always global package directory
问题描述
我们有一个解决方案,其中一些项目是 .net-core 项目,一些是正常"的 .net 4.6.1 项目.在解决方案级别,我们有一个 NuGet.config-File 来设置存储库路径:
<预><代码><配置><配置><add key="repositoryPath" value="packages"/></config></配置>项目 packages.config-Files 中列出的包正在下载到 Nuget.config -> repositoryPath 中指定的路径,但 .net-core 项目文件(通过 PackageReference)中指定的包都下载到全局C:UsersUSERNAME.nugetpackages 中的包目录.
我是使用 Visual Studio 2017 还是通过 nuget.exe 手动执行都没有关系..net-core 项目只是忽略了 NuGet.config.
我们在这里做错了什么?
好的.知道了.将以下标记添加到 .csproj 文件即可:
...<RestorePackagesPath>包</RestorePackagesPath></PropertyGroup>
来源:https://github.com/NuGet/Home/wiki/%5BSpec%5D-NuGet-settings-in-MSBuild
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:UsersUSERNAME.nugetpackages.
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?
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
这篇关于.net-core 项目还原的包目标始终是全局包目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!