VSTS dotnet Nuget Pack: Is not a valid version string
Asked Answered
S

4

6

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.

Syllogism answered 11/7, 2018 at 14:50 Comment(0)
S
5

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.

Sukhum answered 31/7, 2018 at 2:57 Comment(1)
My own problem was that my version started with v0.1.0 the v was the problem.Suk
G
2

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

Glacialist answered 13/10, 2022 at 13:27 Comment(0)
C
1

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

Crochet answered 12/7, 2018 at 9:27 Comment(10)
my variable is set up like that and it still errors outSyllogism
@JoeJazdzewski What about removing the string "-beta"? just use the variable $(Build.BuildNumber)Crochet
when "-beta" is removed it works but I am trying to make a prerelease build. I have also tried other words besides "-beta" and I get the same thingSyllogism
@JoeJazdzewski Just try adding the "beta" as prefix like this Beta-$(Build.BuildNumber), then check if that works.Crochet
@JoeJazdzewski Any update? Is the string Beta-$(Build.BuildNumber) working for you?Crochet
That broke the build too beta-GuidantFinancial.ServiceBusMessages Dev_2018.7.24.1' is not a valid version string when I used beta-$Build.BuildNumber as my variable valueSyllogism
@JoeJazdzewski Please note that the space cannot be included in the sting, also you can have a try with set variable e.g.: $(packversion) and Beta-$(Build.BuildNumber) as the value. Make sure no space there..Crochet
I am now getting that BuildName_2018.7.25 is not a valid version string. It looks like that the '_' is not a valid character for dotnet packSyllogism
@JoeJazdzewski So, just try to replace the ' _ ' with ' . ', then check it again.Crochet
@JoeJazdzewski Have you resolved the issue? any update?Crochet
S
0

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

"1.2.3+super.beta.01.hello.world"
Stranglehold answered 22/7, 2024 at 8:30 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.