Nuget Configuration in ASP.NET Core 1.0

旧城冷巷雨未停 提交于 2019-12-10 07:24:34

问题


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 and repositoryPath apply only to projects using packages.config. globalPackagesFolder applies only to projects using project.json and projects using the new Visual Studio 2017 project format.



来源:https://stackoverflow.com/questions/36040678/nuget-configuration-in-asp-net-core-1-0

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