Nuget.config文件一般默认存放于 C:\Users{UserName}\AppData\Roaming\NuGet文件夹内。

    1. <?xml version="1.0" encoding="utf-8"?>
    2. <configuration>
    3. <packageSources>
    4. <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    5. </packageSources>
    6. <disabledPackageSources>
    7. <add key="Microsoft and .NET" value="true" />
    8. <config>
    9. <add key="globalPackagesFolder" value="E:\Nuget\.nuget\packages" /> #默认是C:\Users\{username}\.nuget\packages
    10. </config>
    11. </disabledPackageSources>
    12. </configuration>

    这样操作以后NuGet包的存储路径会改为设置地址;坑爹的是有缓存文件和临时文件,现在还没找到怎么去修改它们。微软牛X。

    1. # Clear the 3.x+ cache (use either command)
    2. dotnet nuget locals http-cache --clear
    3. nuget locals http-cache -clear
    4. # Clear the 2.x cache (NuGet CLI 3.5 and earlier only)
    5. nuget locals packages-cache -clear
    6. # Clear the global packages folder (use either command)
    7. dotnet nuget locals global-packages --clear
    8. nuget locals global-packages -clear
    9. # Clear the temporary cache (use either command)
    10. dotnet nuget locals temp --clear
    11. nuget locals temp -clear
    12. # Clear the plugins cache (use either command)
    13. dotnet nuget locals plugins-cache --clear
    14. nuget locals plugins-cache -clear
    15. # Clear all caches (use either command)
    16. dotnet nuget locals all --clear
    17. nuget locals all -clear

    从 Visual Studio 2017 开始,使用“工具”>“NuGet 包管理器”>“包管理器设置”菜单命令,然后选择“清除所有 NuGet 缓存” 。
    image.png