简体   繁体   中英

Package Manager in VS2015 RC fails on installing/restoring some packages

I'm trying to install a nuget package - NGenerics.1.4.1 from nuget.org ( https://www.nuget.org/packages/NGenerics/ ) into a ASP.NET 5 project (website). Package Manager fails with UriFormatException. After that a reference is added into Reference folder in the Solution Explorer but with yellow triangle ('warning').
The error added into the Error List: "Dependency NGenerics >= 1.4.1.0 could not be resolved".
I also tried to install from a local folder registry.

Here's the bug on msconnect .

I wonder whether somebody experienced the same issue as I couldn't find anything in google. Also any workarounds are welcome.

Package Manager's Output:

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.

I stumbled across the same issue today with NuGet 2.8.5 on Visual Studio 2013. @Shrike's answer helped me find out it's the specification of my relative path in a custom NuGet.config. Since it appears System.Uri must be able to parse it, all you have to do is ensure the relative path is a proper, legal URI. Relative file URIs must start with './' (obv don't use backslashes either, they're a Windows Thing!). See c# type to handle relative and absolute URI's and local file paths

Eg Use:

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

instead of:

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

Removing the local feed is not a good idea, as you now have to restore from a different feed, which may not be what you want (personally, I wouldn't bet my builds on the nuget gallery given it's track record of downtime...)

Finally I found out what was wrong. I had ".nuget\\NuGet.config" file somewhere above of my solution in folder structure.
That NuGet.config contained a package source with relative file path:

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

As I removed that packageSource Package Manager in VS started working.

It's kinda ridiculous.

Hope it helps somebody not to loose so many hours as me.

After wasting about two hours on the exception I found that my package source is added to the disabledPackageSources section in .nuget\\NuGet.config. I just had to remove it from the disabled list.

 <disabledPackageSources>
    <add key="RaNuget" value="true" />
  </disabledPackageSources>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM