更改Visual Studio 2017使用的NuGet软件包文件夹 [英] Change NuGet package folders used by Visual Studio 2017

查看:394
本文介绍了更改Visual Studio 2017使用的NuGet软件包文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在任何 csproj project.json <中不再有个软件包解决方案文件夹/ code>为基础的.NET Core项目。

There is no more packages solution folder in any csproj or project.json-based .NET Core project.

NuGet CLI 获取使用的缓存文件夹列表:

NuGet CLI gets the list of used cache folders:

nuget locals all -list

响应:

http-cache: C:\Users\<foo>\AppData\Local\NuGet\v3-cache
global-packages:  C:\Users\<foo>\.nuget\packages\
temp: C:\Users\<foo>\AppData\Local\Temp\NuGetScratch

如何更改或覆盖这些位置?

How to change or override these locations?

推荐答案

缓存位置



.NET Core和Visual Studio 2017不再存在本地解决方案软件包文件夹。

Cache locations

Solution-local packages folders are no longer exist for .NET Core and Visual Studio 2017.

NuGet现在已完全集成到MSBuild中:


解决方案本地程序包文件夹不再使用-程序包现在已使用
是针对用户缓存的%userdata%.nuget解析的,而不是针对
解决方案的特定程序包文件夹。通过使用工作站上
个软件包的共享文件夹,PackageReference可以更快地执行
并减少磁盘空间。

Solution-local packages folders are no longer used – Packages are now resolved against the user’s cache at %userdata%.nuget, rather than a solution specific packages folder. This makes PackageReference perform faster and consume less disk space by using a shared folder of packages on your workstation.

NuGet 4.0+使用至少两个全局软件包位置:

NuGet 4.0+ uses at least two global package locations:


  • 特定于用户:%userprofile%\ .nu​​get\packages\

  • 机器范围:%ProgramFiles(x86)%\Microsoft SDKs\NuGetPackages\

  • User-specific: %userprofile%\.nuget\packages\
  • Machine-wide: %ProgramFiles(x86)%\Microsoft SDKs\NuGetPackages\"

您可以使用以下控制台命令列出所有用户特定的文件夹:

You can list all user-specific folders using the following console command:

nuget locals all -list

请注意,这里没有列出计算机范围的文件夹,但是它是在Visual Studio设置中定义的:

Notice that the machine-wide folder isn't listed there. However, it is defined at Visual Studio settings:

Options -> NuGet Package Manager -> Package Sources



配置文件



NuGet.config 文件位于此处


  • 用户特定:%APPDATA% \NuGet\

  • 机器范围:%ProgramFiles(x86)%\NuGet\Config\

  • User-specific: %APPDATA%\NuGet\
  • Machine-wide: %ProgramFiles(x86)%\NuGet\Config\

可以在多个级别更改和覆盖NuGet设置:

It is possible to change and override NuGet settings at many levels:


  • 项目

  • 解决方案

  • 用户

  • 计算机

  • project
  • solution
  • user
  • machine

甚至更多!在此处阅读有关 NuGet.config 层次优先级排序的更多信息:如何应用设置

And even more! Read more about NuGet.config hierarchical priority ordering here: How settings are applied.

例如, globalPackagesFolder 参数更改程序包缓存位置。看看这个 NuGet.config 示例:

For example, globalPackagesFolder parameter changes a package cache location. Look at this NuGet.config example:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <clear />
    <add key="globalPackagesFolder" value="c:\packages" />
  </config>
</configuration>

这篇关于更改Visual Studio 2017使用的NuGet软件包文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆