.net Nuget无法找到包的版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38734040/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Nuget unable to find version of package
提问by Mathew
Running this command
运行这个命令
nuget.exe restore .\MySolution.sln
gives this error:
给出这个错误:
Unable to find version '1.0.0' of package 'Microsoft.Net.Compilers'.
where the package has previously been installed and restored, but has somehow become corrupt.
先前已安装和恢复软件包的位置,但不知何故已损坏。
回答by Mathew
Turns out simply updating the Nuget version via
原来只是通过更新 Nuget 版本
nuget.exe update -self
to update from 2.8.0 to 3.4.4 was sufficient, and the package now restores correctly.
从 2.8.0 更新到 3.4.4 就足够了,并且该包现在可以正确恢复。
回答by David Gardiner
I had the same problem, but I need to stay with nuget.exe2.8 due to not being able to upgrade the version of .NET Framework installed on our build server (2.8 is the last version that still works with .NET 4.0).
我遇到了同样的问题,但nuget.exe由于无法升级安装在我们的构建服务器上的 .NET Framework 版本,我需要继续使用2.8(2.8 是最后一个仍然适用于 .NET 4.0 的版本)。
The cause turned out to be having nuget.configonly pointing to the v3 API. The solution is to add in the v2 API. eg.
原因原来是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>
回答by armen.shimoon
I was able to resolve this on MacOS using the following command to reset my nuget caches / indexes:
我能够在 MacOS 上使用以下命令重置我的 nuget 缓存/索引来解决此问题:
dotnet nuget locals --clear all
Afterwards I was able to restore my packages successfully:
之后我能够成功恢复我的包:
dotnet restore
回答by FredM
Because I stumbled over this multiple times recently, here is my solution:
因为我最近多次偶然发现这个问题,这是我的解决方案:
- Go to
C:\Users\<User>\AppData\Roaming\NuGet\ - Open
NuGet.config - Add
<add key="keyName" value="path to repository">in<packageSources>. In my case it was a network folder pointing to\\JENKINS\nuGet Repository
- 去
C:\Users\<User>\AppData\Roaming\NuGet\ - 打开
NuGet.config - 添加
<add key="keyName" value="path to repository">在<packageSources>。在我的情况下,它是一个指向的网络文件夹\\JENKINS\nuGet Repository
So it should look similiar to this:
所以它应该看起来类似于:
<?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>
回答by MarPinello
I was facing the same problem, but all your answers were not helping me. Then, I found that my clock was delayed (changed computer that day) and I have not realized that.
我面临着同样的问题,但你所有的答案都没有帮助我。然后,我发现我的时钟延迟了(那天换了电脑),我没有意识到这一点。
This simple correction made it all work normally. The package version does exist, but because it is considered to be in "the future", Nuget was giving this error that version x.x.x could not be found.
这个简单的修正使它一切正常。包版本确实存在,但因为它被认为是“未来”,Nuget 给出了找不到版本 xxx 的错误。
I think this is a huge mistake, because it doesn′t care what time the packages are, if you have a versions list, the datetime it was published is not important.
我认为这是一个巨大的错误,因为它不关心包的时间,如果你有一个版本列表,它发布的日期时间并不重要。
回答by Tereza Tomcova
In our case we upgraded the Nuget extension in VS from 3.3.x to 3.4.4.
在我们的例子中,我们将 VS 中的 Nuget 扩展从 3.3.x 升级到 3.4.4。
You can find the update in Tools menu -> Extensions and Updates -> Updates -> Visual Studio Gallery.
您可以在工具菜单 -> 扩展和更新 -> 更新 -> Visual Studio 库中找到更新。
回答by yu yang Jian
In my case, I have upgraded my Nuget to latest version but still got error.
就我而言,我已将 Nuget 升级到最新版本,但仍然出错。
Then I find that, at Solution Root Folder > 'packages' folder, there's repositories.configin it, and open file you'll see all packages.configthat is being used:
后来我发现,在Solution Root Folder > 'packages' folder,有repositories.config它,并打开文件,你会看到所有packages.config正在使用:
<repository path="..\Common\Luna.Common\packages.config" />
<repository path="..\Common\Luna.ComponentBehaviors\packages.config" />
<repository path="..\Common\Luna.Data\packages.config" />
<repository path="..\Common\Luna.WPF.ApplicationFramework\packages.config" />
<repository path="..\GuyWire\Luna.Basic.GuyWire\packages.config" />
And it is they storing the information 1.0.0:
他们存储信息1.0.0:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Iesi.Collections" version="3.1.0.4000" targetFramework="net40" />
<package id="log4net" version="2.0.3" targetFramework="net40" />
<package id="NHibernate" version="1.0.0" targetFramework="net40" />
<package id="uNhAddIns" version="1.0.0" targetFramework="net40" />
</packages>
Because in fact I'm reference dll by file so I don't need to get by Nuget, I delete the packages.configfile then error solved.
因为实际上我是通过文件引用 dll 所以我不需要通过 Nuget 获取,我删除了packages.config文件然后错误解决了。
回答by arush436
My problem was that I had "Package source" set to my own specific Nuget server instead of All.
我的问题是我将“包源”设置为我自己的特定 Nuget 服务器而不是全部。
回答by Rodolfo
For me, what solved the problem was running the following command inside the solution folder:
对我来说,解决问题的是在解决方案文件夹中运行以下命令:
nuget restore -NoCache -NonInteractive
回答by Hamed Naeemaei
If using dotnet cliand based this documentyou can use dotnet restorecommand with some options such as -f, --no-cacheand --ignore-failed-sources
如果使用dotnet cli并基于此文档,您可以使用dotnet restore带有一些选项的命令,例如-f,--no-cache和--ignore-failed-sources
dotnet restore -f --no-cache --ignore-failed-sources
With this command dotnet core does not search in cached packages
使用此命令 dotnet core 不会在缓存的包中搜索

