Joe Jazdzewski
Joe Jazdzewski

Reputation: 733

VSTS dotnet Nuget Pack: Is not a valid version string

I am trying to create a prerelease build for a .net-standard 2.0 library in VSTS. I have created a build with the following steps

  1. dotnet restore version 2
  2. dotnet build version 2
  3. dotnet pack version 2
  4. nuget push version 2

When I use the environment variable (PackageName) as $(Build.BuildNumber)-beta as my pack version. The pack fails with the error BuildName_2018.7.11.1-beta is not a valid version string. I have previously used this environment variable as my pack version in .net-framework builds with success.

Upvotes: 6

Views: 33249

Answers (4)

Ron
Ron

Reputation: 475

Just use "+" after Major.Minor.Patch and separate words by dot "." Example:

"1.2.3+super.beta.01.hello.world"

Upvotes: 0

CrossBound
CrossBound

Reputation: 146

I think you need to go to only 3 sets of numbers instead of 4. So instead of 2018.7.11.1-beta try 2018.7.11-beta1. I believe 4 sets of numbers will work for the .net dll itself, but not for nuget.

REF: https://learn.microsoft.com/en-us/nuget/concepts/package-versioning

Upvotes: 2

Eddie Chen - MSFT
Eddie Chen - MSFT

Reputation: 29966

The version does not meet Nuget Package Version format. It must start with numbers like following:

1.0.1

6.11.1231

4.3.1-rc

2.2.44-beta1

So you need to remove the strings in your build number format. Refer to this link for details: Package versioning.

Upvotes: 5

Andy Li-MSFT
Andy Li-MSFT

Reputation: 30372

That's because the string $(Build.BuildNumber)-beta is not an environment variable.

You can try to create a variable e.g $(packversion) and set the string $(Build.BuildNumber)-beta as the value of that variable, then use the environment variable $(packversion) in dotnet pack task.


UPDATE:

Seems it can only identify the string which end with number as the version string.

So, just try adding the "beta" as prefix like this Beta-$(Build.BuildNumber), then check if that works.

enter image description here

Upvotes: 1

Related Questions