运行此命令
nuget.exe restore .\MySolution.sln
Run Code Online (Sandbox Code Playgroud)
给出了这个错误:
Unable to find version '1.0.0' of package 'Microsoft.Net.Compilers'.
Run Code Online (Sandbox Code Playgroud)
软件包之前已经安装和恢复的地方,但不知何故已经腐败了.
Mat*_*hew 47
结果只是通过更新Nuget版本
nuget.exe update -self
Run Code Online (Sandbox Code Playgroud)
从2.8.0更新到3.4.4就足够了,包现在可以正确恢复.
arm*_*oon 18
我能够在macOS 上使用以下命令重置我的 NuGet 缓存/索引来解决这个问题:
dotnet nuget locals --clear all
Run Code Online (Sandbox Code Playgroud)
之后我能够成功恢复我的包:
dotnet restore
Run Code Online (Sandbox Code Playgroud)
Dav*_*ner 11
我有同样的问题,但nuget.exe
由于无法升级我们的构建服务器上安装的.NET Framework版本(2.8是仍可与.NET 4.0一起使用的最后一个版本),因此我需要保持2.8.
原因nuget.config
只是指向v3 API.解决方案是添加v2 API.例如.
<configuration>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="nuget v2" value="https://www.nuget.org/api/v2" />
</packageSources>
</configuration>
Run Code Online (Sandbox Code Playgroud)
Ham*_*aei 10
当使用dotnet cli
和基于dotnet Restore document时,您可以使用dotnet restore
带有一些选项的命令,例如-f
、--no-cache
、 和--ignore-failed-sources
:
dotnet restore -f --no-cache --ignore-failed-sources
Run Code Online (Sandbox Code Playgroud)
使用此命令.NET Core 不会在缓存的包中搜索。
因为我最近多次偶然发现这个问题,所以这是我的解决方案:
C:\Users\<User>\AppData\Roaming\NuGet\
NuGet.config
<add key="keyName" value="path to repository">
<packageSources>
就我而言,它是一个指向的网络文件夹\\JENKINS\nuGet Repository
所以它看起来应该类似于:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<packageSources>
<add key="local" value="\\JENKINS\nuGet Repository" />
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<disabledPackageSources />
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
</configuration>
Run Code Online (Sandbox Code Playgroud)