问题
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
- dotnet restore version 2
- dotnet build version 2
- dotnet pack version 2
- 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.
回答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.
回答2:
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.
来源:https://stackoverflow.com/questions/51288536/vsts-dotnet-nuget-pack-is-not-a-valid-version-string