NuGet / Home

Repo for NuGet Client issues
Other
1.5k stars 252 forks source link

"NuGet Package restore failed System.UriFormatException: Invalid URI" with relative local paths #782

Closed JohannesRudolph closed 9 years ago

JohannesRudolph commented 9 years ago

Using NuGet 2.8.5 and local package sources like this (because NuGet gallery has had enough uptime issues for me to tolerate it any longer):

<?xml version="1.0" encoding="utf-8"?>
<configuration>

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

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

</configuration>

I can't restore packages any longer since upgrading to 2.8.5:

Error   210 NuGet Package restore failed for project RowingInMotion.Mobile.BoatApp: 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 NuGet.PackageRepositoryFactory.CreateRepository(String packageSource)
   at NuGet.VisualStudio.CachedRepositoryFactory.GetPackageRepository(String source)
   at NuGet.VisualStudio.CachedRepositoryFactory.CreateRepository(String source)
   at NuGet.VisualStudio.VsPackageSourceRepository.GetActiveRepository()
   at NuGet.VisualStudio.VsPackageManagerFactory.IsAggregateRepository(IPackageRepository repository)
   at NuGet.VisualStudio.VsPackageManagerFactory.CreatePackageManagerWithAllPackageSources(IPackageRepository repository)
   at NuGet.VisualStudio.VsPackageManagerFactory.CreatePackageManagerWithAllPackageSources()
   at NuGet.VsEvents.PackageRestorer.RestorePackage(PackageReference package)
   at NuGet.VsEvents.PackageRestorer.RestorePackages(String packageReferenceFileFullPath, IFileSystem fileSystem)
   at NuGet.VsEvents.PackageRestorer.PackageRestore(ProjectPackageReferenceFile projectPackageReferenceFile).       0   0   

Others have the same issue too: http://stackoverflow.com/questions/30243447/package-manager-in-vs2015-rc-fails-on-installing-restoring-some-packages

JohannesRudolph commented 9 years ago

I think this is a simply an issue of changed behavior in Nuget. See http://stackoverflow.com/a/30827650/125407 for required user fix. Maybe provide a better error message in this case?

yishaigalatzer commented 9 years ago

@JohannesRudolph I understand that NuGet down time is an issue for you and we take it seriously. We are going to change this track record as you call it.

Having said that having a local source is not a bad idea.

Note that going with a local package path is going to make things a lot slower (with the current bits). In NuGet3 we are implementing a new local folder structure that will make things faster.

Some comments

  1. You probably want your local source to be pointing to a user folder instead of a relative path and setup globally on the machine. This will mean projects can easily share the source.
  2. The stackoverflow issue you are referring to is about asp.net 5 project. That project system is not using the NuGet codebase (for now at least), I filed an issue there as well https://github.com/aspnet/Home/issues/669.
yishaigalatzer commented 9 years ago

Related (but not the same as) - https://github.com/NuGet/Home/issues/779

Also are you saying this used to work in previous versions of nuget.exe

yishaigalatzer commented 9 years ago

The work here:

  1. Provide a better error message - Include the faulty uri in the message and point of possible formats
  2. Verify there is a way to support relative paths and document it.
  3. Verify the UI allows adding relative paths, and does the right manipulations to store the data in the config file
theo-albers commented 9 years ago

NuGet 2.8.5 indeed breaks previous behaviour. I registered a new bug for it, https://github.com/NuGet/NuGetGallery/issues/2625

yishaigalatzer commented 9 years ago

Verified this works in nuget.exe 3.3.

Also note we implemented a new feature in nuget 3.3 (nuget init, nuget add) that lets you create a much more efficient local package source, as described in this blog - http://blog.nuget.org/20150922/Accelerate-Package-Source.html

theo-albers commented 9 years ago

Hey Yishai, is there more information of the new NuGet 3.3 init and add commands? The blog didn't reveal that part.

yishaigalatzer commented 9 years ago

They are in pr on the nugetdocs repo. Will go live soonish