Since August 2016, the NuGet package manifest (.nuspec) has supported the <repository> XML element. This is an optional metadata element with two optional attributes: type and url. Presumably, the purpose of this element is to communicate to package consumers the version control type and location of the source code used to produce the package.
Currently, I see no NuGet documentation about this property and no support for it in the various NuGet UIs (Visual Studio and the nuget.org web gallery).
This metadata adds additional valuable information about a package that augments the existing <projectUrl> package metadata field. Project URL seems to me like a "product" or "company" specific website and repository URL is where the source code (and maybe even bug tracker) lives. If a project has project site that is different than their GitHub repository, this differentiation is helpful to package consumers.
This property is already widely adopted on nuget.org but is not surfaced in any UI or used for any scenario. Let's give an easy win to our package consumers!
As far as I can tell, the repository metadata has the following history:
type is added to the project.json schema (PR)repository node is added to project.json for dnu sources (announcement)dnu sources and the repository node are removed (announcement)url is added to the project.json schema (PR)packOptions (PR)packOptions is announced (accouncement)<repository> to the .nuspec and to the .csproj (commit)packOptions (PR)dev branch (PR)This is an odd history that indicates decent support and documentation when it was initially implemented by the ASP.NET but has since fallen to the wayside when it was adopted by the NuGet team.
I walked the entire nuget.org catalog (source) and gathered the following information concerning the real life usage of <repository>. This data is up-to-date as of November 1, 2017.
Some high level points about packages with <repository> metadata:
<repository> metadata.type attribute.url attribute. 225 don't have a url attribute.System.Uri. 189 are not parsable.type attribute have git (case insensitive).type attribute balue is GitHub (1,977 packages).url attribute have "https://" URLs.url attribute have "http://" URLs.url attribute have "git://" URLs.
The top 10 packages that have <repository> are:
ID | Version | Downloads
-- | -- | --
Newtonsoft.Json | 10.0.3 | 3,816,231
Castle.Core | 4.1.1 | 918,532
Castle.Core | 4.1.0 | 497,535
Microsoft.Rest.ClientRuntime | 2.3.8 | 460,118
Microsoft.Extensions.Primitives | 2.0.0 | 368,589
Microsoft.VisualStudio.Web.CodeGeneration.Tools | 1.0.0 | 368,363
Autofac | 4.6.0 | 359,598
Microsoft.Extensions.DependencyInjection.Abstractions | 2.0.0 | 351,539
Microsoft.Extensions.Options | 2.0.0 | 341,419
There is a huge variety of type and url values. We should document:
In my opinion we should strongly suggest http:// or https:// URLs that are intended for viewing in web browsers, as opposed to, say, .git URLs: https://github.com/NuGet/NuGetGallery.git. This allows us to make clickable links in VS or in the browser, after all.
git:// links are nice because you can probably run git clone directly on them, but this is still achievable with http:// or https:// links by just navigating there in your browser and find the inevitable "copy clone command" button (e.g. on GitHub).
Let's make the repository URL clickable in the NuGet UIs!

If the repository URL is http:// or https://, show this link, just like the project URL.
An analogous change should be made by the VS client.
Thoughts?
/cc @anangaur @karann-msft @skofman1 @rrelyea
I liked this idea to showing repository urls in NuGet.org and at some point in time in VS client too. This will also help consumers to know more about the package and if anything is wrong, then directly log an issue on their respective repository instead of filling a NuGet support request.
Not to rain on this proposal, but here is an argument against adding a repository link.
In my opinion repository url was added to eventually get to a Switch PackageReference -> Project from Source feature, which is a common ask.
The repository has type=git not type=website, it just happens that for github the url works has both, but in my opinion it is wrong to open these urls in the web browser.
It should be possible to write a tool to read the nuspec, and if it has type git, it runs git clone on the url. If nuget.org were to treat this property as projectUrl2 then my guess is that a lot of packages would end up using this incorrectly and it would hard to create a tool like that.
I also think that there is minimal value in having 2 project urls, if the repository web site is important, the project url should link to it, or the site it goes to should link to it.
I'm not sure how useful it would be, but I would rather see nuget.org read the actual git respository and surface information about whether or not the project is still active.
The repository has type=git not type=website, it just happens that for github the url works has both, but in my opinion it is wrong to open these urls in the web browser.
I don't have a strong opinion here, but there is definitely needs to be some documentation about what the value means. As it stands today, users are guessing.
Hey @rrelyea @skofman1, is this still on your radar? In 2.1, aspnet packages include repository url and commit metadata. We'd love to see the gallery display this somehow. Is this proposal complete enough that you would consider accepting a PR if we could do the work?
@natemcmaster On our radar for sure. Not up in the backlog yet. We will factor this into NuGet Package Debugging & Symbols Improvements
/cc: @diverdan92
A customer created a PR: https://github.com/NuGet/docs.microsoft.com-nuget/pull/900
Documentation proposed: https://github.com/NuGet/docs.microsoft.com-nuget/pull/930
So we would need to push this forward. Here's how the landscape look in terms of package management.
NPM does it on the first page and even allow to split between the Homepage and the Repository URL.

If we look at Newtonsoft, even thought they had the attribute for a while now...

It still does not show up in the project description.

It doesn't look like something that is hard to implement since the nuspec doesn't need to be changed.
Is it something that can be PR'd?
/cc @spboyer
@MaximRouiller good timing. I was thinking about this last night too and drafted this PR: https://github.com/NuGet/NuGetGallery/pull/6151
Pinging this to keep this alive.
We have a PR, we don't have any spec... I'd love an estimated timeframe on when we plan on getting this solved/merged.
I'd also love to get the PR merged. There is an internal email thread going on this one, and it seems like there are two things holding this up:
The work we decided to do here:
Where is the spec for this?
cc: @anangaur, @diverdan92
Spec announced at https://github.com/NuGet/Announcements/issues/30
...get to a Switch PackageReference -> Project from Source feature, which is a common ask.
Hey @emgarten, just wondering if there's a github issue tracking this? I'm also interested in this feature. Thanks and sorry for hijacking the thread for this.
Hey @emgarten, just wondering if there's a github issue tracking this? I'm also interested in this feature. Thanks and sorry for hijacking the thread for this.
@rrelyea , perhaps you know?
On the .NET Core side, we have this issue: https://github.com/dotnet/sdk/issues/1151
On the .NET Core side, we have this issue:
Mmm, not sure I misunderstood the feature then; I was thinking it's more to do with NuGet rather than .NET Core. (More info: https://github.com/ctaggart/SourceLink/issues/320)
I think what @emgarten was suggesting was that you could use repository url and commit data from the package nuspec to replace a PackageReference with a source code (i.e a ProjectReference). Implementing this would likely require an SDK change (https://github.com/dotnet/sdk/issues/1151 is about making it possible to swap a PackageRef for a ProjectRef) and some NuGet features to fetch source code based on package metadata. This feature outside the scope of what this particular issue is about. Not sure if an issue exists on the NuGet side to actually build this feature.
Most helpful comment
I think what @emgarten was suggesting was that you could use repository url and commit data from the package nuspec to replace a PackageReference with a source code (i.e a ProjectReference). Implementing this would likely require an SDK change (https://github.com/dotnet/sdk/issues/1151 is about making it possible to swap a PackageRef for a ProjectRef) and some NuGet features to fetch source code based on package metadata. This feature outside the scope of what this particular issue is about. Not sure if an issue exists on the NuGet side to actually build this feature.