Home: Star wildcard doesn't match against numeric build number in pre-release tag

Created on 13 Jun 2017  路  5Comments  路  Source: NuGet/Home

We're seeing a strange behavior in NuGet restoring. Given the following project:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.AspNetCoreModule" Version="1.0.0-*" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0-*" />
  </ItemGroup>

</Project>

And the following feeds:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <!--To inherit the global NuGet package sources remove the <clear/> line below -->
    <clear />
    <add key="AspNetCore" value="https://dotnet.myget.org/F/aspnetcore-ci-dev/api/v3/index.json" />
    <add key="NuGet" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
</configuration>

We're getting this error on dotnet restore:

MSBUILD : error NU1102: Unable to find package Microsoft.AspNetCore.AspNetCoreModule with version (>= 1.0.0)\r [C:\Users\anurse\Documents\visual studio 2017\Projects\ConsoleApp4\ConsoleApp4.sln]
MSBUILD : error NU1102:   - Found 1 version(s) in AspNetCore [ Nearest version: 1.0.0-10049 ]\r [C:\Users\anurse\Documents\visual studio 2017\Projects\ConsoleApp4\ConsoleApp4.sln]
MSBUILD : error NU1102:   - Found 0 version(s) in nuget.org [C:\Users\anurse\Documents\visual studio 2017\Projects\ConsoleApp4\ConsoleApp4.sln]

On the feed, both packages (Microsoft.AspNetCore.AspNetCoreModule and Microsoft.AspNetCore.Mvc) only have pre-release versions available with the matching prefix (see https://dotnet.myget.org/gallery/aspnetcore-ci-dev). However, Microsoft.AspNetCore.Mvc resolves correctly, while Microsoft.AspNetCore.AspNetCoreModule does not.

Replacing the -* with a specific package version (i.e. 1.0.0-10049) results in a successful restore.

The only difference I can see is that for Microsoft.AspNetCore.AspNetCoreModule (which fails to restore), the only versions available have a format of 1.0.0-10049 whereas Microsoft.AspNetCore.Mvc's latest version is 2.0.0-preview3-25659. It seems that perhaps the matching is not properly handling purely numeric pre-release tags?

.NET CLI Version: 2.0.0-preview2-006349
NuGet.Versioning Version: 4.3.0-preview2-4095

Note I tried older .NET CLI versions, and this does still repro on 1.0.4 as far as I can tell (NuGet.Versioning version: 4.0.0-rtm-2283)

/cc @Tratcher

Duplicate

Most helpful comment

Dupe of https://github.com/NuGet/Home/issues/4513

The fix for this would make 1.0.0-* the range >= 1.0.0-0, which fails to parse on older clients if this were to get into a nuspec. For some reason NuGet 2.x enforces the rule that pre-release labels cannot start with a number which is not part of the semver spec.

All 5 comments

/cc @muratg @emgarten @davidfowl

Dupe of https://github.com/NuGet/Home/issues/4513

The fix for this would make 1.0.0-* the range >= 1.0.0-0, which fails to parse on older clients if this were to get into a nuspec. For some reason NuGet 2.x enforces the rule that pre-release labels cannot start with a number which is not part of the semver spec.

Thanks! Not sure why we didn't see that when first looking :)

@anurse thanks for the great repro. I'm hoping this will get fixed soon, it's the issue slowing this down is primarily the 2.x client handling of it, we just need to make sure this change won't affect package creation.

Was this page helpful?
0 / 5 - 0 ratings