How to to produce both release and pre-release packages from one nuspec in VSTS?

耗尽温柔 提交于 2019-12-06 15:42:36

To produce two packages by a nuspec, you can use two NuGet tasks (NuGet custom instead NuGet pack):

NuGet task:

Command: custom

Command and arguments:

pack $(Build.SourcesDirectory)\Package.nuspec -Version $(Build.BuildNumber) -OutputDirectory $(build.artifactstagingdirectory)

NuGet task:

Command: custom

Command and arguments:

pack $(Build.SourcesDirectory)\Package.nuspec -Version $(Build.BuildNumber) -Suffix beta -OutputDirectory $(build.artifactstagingdirectory)

If you set the $(Build.BuildNumber) as the format like MyProject-Daily_1.0.94.0 while you want to add the version for nuget package as 1.0.94.0, you can define a variable in your build definition and set the value by cutting the substring of $(Build.BuildNumber). detail steps as below:

In Variables Tab, add a variable (such as version) with any value (such as temp).

Add a PowerShell Task before NuGet tasks with the settings,

Type: Inline Script

Inline Script:

$s1=$(Build.BuildNumber).split('_')[1].split(' ')
Write-Host "##vso[task.setvariable variable=version]$s1"

Then in the NuGet Custom tasks use $(version) to replace $(Build.BuildNumber) for -version option. Such as nuget pack -version $(version).

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