[BUG] NuGet: Support build metadata properly

The repo for the following package is https://github.com/verybadcat/CSharpMath.

After creating a NuGet.Config file as specified (feed is https://nuget.pkg.github.com/verybadcat/index.json), the command dotnet add GitHubReport package CSharpMath.SkiaSharp --version 0.4.2-ci-9db8a6dec29202804764fab9d6f7f19e43c3c083\+2020.06.10-07.22.37 fails:

  Determining projects to restore...
  Writing C:\Users\hadri\AppData\Local\Temp\tmpB503.tmp
info : Adding PackageReference for package 'CSharpMath.SkiaSharp' into project 'C:\Users\hadri\source\repos\GitHubReport_Nightly\GitHubReport\GitHubReport.csproj'.
info : Restoring packages for C:\Users\hadri\source\repos\GitHubReport_Nightly\GitHubReport\GitHubReport.csproj...
info :   CACHE https://api.nuget.org/v3-flatcontainer/csharpmath.skiasharp/index.json
info :   CACHE https://nuget.pkg.github.com/verybadcat/download/csharpmath.skiasharp/index.json
info :   GET https://nuget.pkg.github.com/verybadcat/download/csharpmath.skiasharp/0.4.2-ci-9db8a6dec29202804764fab9d6f7f19e43c3c083/csharpmath.skiasharp.0.4.2-ci-9db8a6dec29202804764fab9d6f7f19e43c3c083.nupkg
info :   NotFound https://nuget.pkg.github.com/verybadcat/download/csharpmath.skiasharp/0.4.2-ci-9db8a6dec29202804764fab9d6f7f19e43c3c083/csharpmath.skiasharp.0.4.2-ci-9db8a6dec29202804764fab9d6f7f19e43c3c083.nupkg 1315ms
info :   GET https://api.nuget.org/v3-flatcontainer/csharpmath.skiasharp/index.json
info :   GET https://nuget.pkg.github.com/verybadcat/download/csharpmath.skiasharp/index.json
info :   OK https://nuget.pkg.github.com/verybadcat/download/csharpmath.skiasharp/index.json 592ms
info :   CACHE https://nuget.pkg.github.com/verybadcat/download/csharpmath.skiasharp/index.json
error: The feed 'CSharpMathNightly [https://nuget.pkg.github.com/verybadcat/index.json]' lists package 'CSharpMath.SkiaSharp.0.4.2-ci-9db8a6dec29202804764fab9d6f7f19e43c3c083' but multiple attempts to download the nupkg have failed. The feed is either invalid or required packages were removed while the current operation was in progress. Verify the package exists on the feed and try again.
error:   Unable to find package 'CSharpMath.SkiaSharp.0.4.2-ci-9db8a6dec29202804764fab9d6f7f19e43c3c083'.

The important line is

info :   NotFound https://nuget.pkg.github.com/verybadcat/download/csharpmath.skiasharp/0.4.2-ci-9db8a6dec29202804764fab9d6f7f19e43c3c083/csharpmath.skiasharp.0.4.2-ci-9db8a6dec29202804764fab9d6f7f19e43c3c083.nupkg 1315ms

Opening the URL

https://nuget.pkg.github.com/verybadcat/download/csharpmath.skiasharp/0.4.2-ci-9db8a6dec29202804764fab9d6f7f19e43c3c083/csharpmath.skiasharp.0.4.2-ci-9db8a6dec29202804764fab9d6f7f19e43c3c083.nupkg

, this line is outputted:

{"error":"Version \"0.4.2-ci-9db8a6dec29202804764fab9d6f7f19e43c3c083\" does not exist on nuget package \"csharpmath.skiasharp\" under owner \"verybadcat\""}

This is because

https://nuget.pkg.github.com/verybadcat/download/csharpmath.skiasharp/0.4.2-ci-9db8a6dec29202804764fab9d6f7f19e43c3c083+2020.06.10-07.23.29/csharpmath.skiasharp.0.4.2-ci-9db8a6dec29202804764fab9d6f7f19e43c3c083+2020.06.10-07.23.29.nupkg

is the actual URL.

Contrast this with e.g. Xamarin.Forms on NuGet.org, version

4.7.0.848-pre3+sha.9bae2b34e-azdo.3764102

, the download URL is

https://api.nuget.org/v3-flatcontainer/xamarin.forms/4.7.0.848-pre3/xamarin.forms.4.7.0.848-pre3.nupkg

, which has NO build metadata in the name.

Therefore, the NuGet GitHub Package registry appending the build metadata to the download URL is incompatible with existing .NET tooling and should be fixed. Thanks.

Hi @happypig375,

I didn’t know NuGet supported SemVer2 and metadata!

I haven’t been able to find much documentation about it. Here are a couple of blog entries and the docs was able to find:



https://articles.assembla.com/en/articles/2729137-semver2-support-for-nuget-endpoints-on-myget

I’m interested to know how you’re using metadata and what problem you’re hoping to solve? Do you want to be able to push multiple build of the same version (like Maven’s SNAPSHOT versions) or are you using it to link back to the commit a package version was built from?

Thanks,
Jamie.

2 Likes

Multiple versions only differentiable by build metadata are considered the same version. This is how SemVer works. I am using metadata to store build dates - the package commit is encoded in the prerelease section.

The issue is that the GitHub Package registry is incompatible with existing .NET tooling. It should follow NuGet.org in package URL generation.

@happypig375 am I understanding this correctly.

  • If a NuGet registry supports storing the +metadata as part of a package version (which GitHub Packages apparently does), it should also support returning the package when the metadata itsn’t metadata
  • Alternatively a NuGet registry could simply ignore metadata when storing and fetching a package version

It sounds like the easy fix would be to simply ignore everything after # in a package version. :thinking:

The metadata IS metadata, no matter the content. Just support it properly, thanks.

If NuGet.org does this, then GitHub Packages should too.

The metadata IS metadata, no matter the content. Just support it properly, thanks.

Sorry, I meant when the metadata isn’t specified. :wink:

1 Like