VSTS dotnet Nuget Pack: Is not a valid version string

若如初见. 提交于 2021-02-07 10:36:36

问题


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.


回答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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!