问题
In our existing solution we have a NuGet.Config file with the following content:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
<config>
<add key="repositorypath" value="NuGetPackages" />
</config>
</configuration>
With this config we tell NuGet to store all packages in the "NuGetPackages" folder. This works fine for all our existing Projects (WebApi, Libraries, ...), but if I add a new ASP.NET Core project, the packages are stored in the C:\Users\<username>\.dnx\packages
folder.
Is there a way to change the package folder on solution level?
Thanks!!
回答1:
Yeah, you can use the global.json
for that:
{
"packages": "NuGetPackages",
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-rc1-update1"
}
}
See: https://github.com/aspnet/Home/wiki/Package-Locations
回答2:
You might need to use globalPackagesFolder
instead of repositoryPath
key as stated in NuGet documentation:
Note:
dependencyVersion
andrepositoryPath
apply only to projects usingpackages.config
.globalPackagesFolder
applies only to projects usingproject.json
and projects using the new Visual Studio 2017 project format.
来源:https://stackoverflow.com/questions/36040678/nuget-configuration-in-asp-net-core-1-0