Change NuGet package folders used by Visual Studio 2017

前端 未结 3 891
独厮守ぢ
独厮守ぢ 2020-12-04 18:04

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

NuGet CLI gets the list of us

相关标签:
3条回答
  • 2020-12-04 18:27

    Copying the .nuget folder (c:\users{username}.nuget) from the development pc which has an internet connection and the updated packages, to the pc which doesn't have the internet connection also worked for me.

    0 讨论(0)
  • 2020-12-04 18:30

    Cache locations

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

    NuGet is now fully integrated into MSBuild:

    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+ uses at least two global package locations:

    • 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
    

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

    Options -> NuGet Package Manager -> Package Sources
    

    Configuration files

    NuGet.config files are located here:

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

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

    • project
    • solution
    • user
    • machine

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

    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>
    
    0 讨论(0)
  • 2020-12-04 18:43

    From the MS docs:

    global‑packages

    • Windows: %userprofile%\.nuget\packages
    • Mac/Linux: ~/.nuget/packages

    Override using the NUGET_PACKAGES environment variable, the globalPackagesFolder or repositoryPath configuration settings (when using PackageReference and packages.config, respectively), or the RestorePackagesPath MSBuild property (MSBuild only). The environment variable takes precedence over the configuration setting.

    0 讨论(0)
提交回复
热议问题