Bug 42985 - Failure to parse URL for NuGet repository
Summary: Failure to parse URL for NuGet repository
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: NuGet (show other bugs)
Version: 6.0.0 (C7)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: master
Assignee: Matt Ward
Depends on: 43032
  Show dependency tree
Reported: 2016-08-02 09:39 UTC by Mikko Tormanen
Modified: 2016-09-27 13:16 UTC (History)
0 users

See Also:
Is this bug a regression?: ---
Last known good build:

Screenshot (51.35 KB, image/png)
2016-08-02 09:39 UTC, Mikko Tormanen

Description Mikko Tormanen 2016-08-02 09:39:20 UTC
Created attachment 16859 [details]

Description of Problem:
When trying to add our internal NuGet repository to be used in Xamarin, it fails to parse the URL 

Steps to reproduce the problem:
1. Add a NuGet repo in Preferences resembling this URL format: https://somerepo.pkgs.visualstudio.com/_packaging/tps/nuget/v2
2. Load a solution and try to add a packagae to a project from this repo.

Actual Results:
Add Packages window shows an error: "Invalid URI: The hostname could not be parsed."

Expected Results:
All packages from this repo are listed.

How often does this happen? 
Every time.

Additional Information:
Comment 1 Matt Ward 2016-08-02 11:12:35 UTC
1) Can you attach the full IDE information? (About dialog - Show Details)

2) Also can you attach the exception callstack from the IDE log? (Help - Open Log Directory).

You should be able to mark the comment/attachment as private if it contains sensitive information, otherwise remove that information before attaching.

I use a VSTS package source which has a similar url and that seems OK for me:

Comment 2 Mikko Tormanen 2016-08-02 12:13:13 UTC
Hi Matt,

Bugzilla won't allow me to set attachments as private. Can you please set these permissions for me? I will then attach the log files.

Thanks in advance,

=== Xamarin Studio Community ===

Version 6.0.2 (build 73)
Installation UUID: 7a8e0fb8-1b19-460c-ab67-8e3e07af1a17
	Mono 4.4.2 (mono-4.4.0-branch-c7sr1/f72fe45) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 404020011

=== Xamarin.Profiler ===

Not Installed

=== Apple Developer Tools ===

Xcode 7.3.1 (10188.1)
Build 7D1014

=== Xamarin.Mac ===

Not Installed

=== Xamarin.Android ===

Not Installed

=== Xamarin Android Player ===

Not Installed

=== Xamarin.iOS ===

Not Installed

=== Build Information ===

Release ID: 600020073
Git revision: a6f7a24a9723a2d4f5d33c176615b0d44703ab5b
Build date: 2016-07-26 13:36:15-04
Xamarin addins: f5acb37866a0141bc5ddbe95118f18dae4014568
Build lane: monodevelop-lion-cycle7-sr1

=== Operating System ===

Mac OS X 10.11.6
Darwin mikkos-mbp.guest.corp.microsoft.com 15.6.0 Darwin Kernel Version 15.6.0
    Thu Jun 23 18:25:34 PDT 2016
    root:xnu-3248.60.10~1/RELEASE_X86_64 x86_64
Comment 4 Matt Ward 2016-08-02 15:46:43 UTC
VSTS is now using a different url:

Old url style:


Newer url style:


The newer url style cannot be used currently. The older style url still works and is the current workaround.

Some initial tests:

1) Xamarin Studio 6.0.2 on Windows is OK.
2) Xamarin Studio 6.0.2, 6.0.1 and 5.10 all fail unless the url includes "DefaultCollection"
3) Xamarin Studio 6.1 is OK

Xamarin Studio 6.1 uses NuGet v3, older versions use NuGet v2, so I am assuming NuGet v3 is using a different way to connect to the url.

The exception callstack:


I will run some tests with older versions of Mono to see if this is a regression.
Comment 5 Matt Ward 2016-08-02 17:40:11 UTC
It does not seem to be a regression in Mono. I tried a few versions: 4.4.0, 4.2.2, 4.0.4 and 3.12.0 all of which fail with the same error.
Comment 6 Matt Ward 2016-08-03 16:49:22 UTC
Had some time to look into this a bit further. Created a simple console app that uses NuGet to repro the problem:


There are two problems here:

1) VSTS is returning incorrect urls in its results when using a url without DefaultCollection in it:

<feed xml:base="https://_packaging/VSTSTest/nuget/v2">
  <title />
  <link rel="self" href="https://_packaging/VSTSTest/nuget/v2/Packages" />

When the DefaultCollection url is used the urls are correct. Which seems to be a VSTS bug.

2) Mono cannot parse urls that start with an underscore.

So the following code will trigger the same exception:

    // Causes 'Invalid URI: The hostname could not be parsed.'
    var uri = new Uri ("https://_foo/bar.html");
On Windows the above code works with no exception being thrown.
Comment 7 Matt Ward 2016-09-27 13:16:59 UTC
This seems to be OK with Mono 4.8.0. The VSTS feed is still returning incorrect urls but Mono now parses them without an exception being thrown.

Note You need to log in before you can comment on or make changes to this bug.