VS2015 RC中的程序包管理器无法安装/恢复某些程序包

时间:2015-05-14 17:20:17

标签: nuget asp.net-core visual-studio-2015 dnx

我尝试将nuget包 - NGenerics.1.4.1从nuget.org(https://www.nuget.org/packages/NGenerics/)安装到ASP.NET 5项目(网站)中。程序包管理器因UriFormatException而失败。之后,参考文件将添加到解决方案资源管理器中的参考文件夹中,但带有黄色三角形('警告')。 错误列表中添加了错误:"依赖NGenerics> = 1.4.1.0无法解决"。
我还尝试从本地文件夹注册表安装。

这是msconnect上的错误。

我想知道是否有人遇到过同样的问题,因为我无法在Google中找到任何内容。也欢迎任何解决方法。

包管理器的输出:

Installing NuGet package NGenerics.1.4.1.
Successfully installed 'NGenerics.1.4.1' to Samples.AjaxDemo2.
========== Finished ==========
Restoring packages for D:\Work\Apps\Samples.AjaxDemo2\project.json
----------
System.UriFormatException: Invalid URI: The format of the URI could not be determined.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   at System.Uri..ctor(String uriString)
   at Microsoft.Framework.PackageManager.PackageSourceUtils.CreatePackageFeed(PackageSource source, Boolean noCache, Boolean ignoreFailedSources, Reports reports)
   at Microsoft.Framework.PackageManager.RestoreCommand.AddRemoteProvidersFromSources(List`1 remoteProviders, List`1 effectiveSources)
   at Microsoft.Framework.PackageManager.RestoreCommand.<RestoreForProject>d__74.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Framework.PackageManager.RestoreCommand.<>c__DisplayClass73_0.<<ExecuteCommand>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Framework.PackageManager.RestoreCommand.<ExecuteCommand>d__73.MoveNext()
----------
Restore failed
Invalid URI: The format of the URI could not be determined.

3 个答案:

答案 0 :(得分:1)

我今天在Visual Studio 2013上遇到了与NuGet 2.8.5相同的问题。@ Shrike的回答帮助我发现它是我在自定义NuGet.config中的相对路径的规范。由于System.Uri必须能够解析它,所以您需要做的就是确保相对路径是合法的合法URI。相对文件URI必须以'./'开头(obv也不要使用反斜杠,它们是Windows Thing!)。见c# type to handle relative and absolute URI's and local file paths

E.g。使用:

<add key="local-feed" value="./lib/nuget-feed" />

而不是:

<add key="local-feed" value="lib/nuget-feed" />

删除本地Feed并不是一个好主意,因为您现在必须从不同的Feed中恢复,这可能不是您想要的(个人而言,我不会打算在nuget图库上建立它的跟踪记录停机时间...)

答案 1 :(得分:0)

最后我发现了什么是错的。我在文件夹结构的解决方案之上的某处有“.nuget \ NuGet.config”文件 NuGet.config包含具有相对文件路径的包源:

<configuration>
  <packageSources>
    <add key="local" value="..\..\..\Release"/>
  </packageSources>
</configuration>

当我删除VS中的packageSource包管理器开始工作时。

这有点荒谬。

希望有人不要像我这样花很多时间。

答案 2 :(得分:0)

在异常上浪费了大约两个小时之后,我发现我的包源被添加到.nuget \ NuGet.config中的disabledPackageSources部分。我只需将其从禁用列表中删除。

 <disabledPackageSources>
    <add key="RaNuget" value="true" />
  </disabledPackageSources>
相关问题