如何从VSTS中的一个nuspec生成发布和预发布软件包? [英] How to to produce both release and pre-release packages from one nuspec in VSTS?

查看:127
本文介绍了如何从VSTS中的一个nuspec生成发布和预发布软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我的构建每次都会生成两个版本都更高的软件包:

Currently my build produces both packages having a newer version every time:

Release: Automatic package versioning = Use the build number
Pre-release: Additional build properties = Version=$(user.BuildFullVersion)-beta

并且只有一个nuspec具有版本的占位符:

And the only one nuspec has a placeholder to version:

<version>$version$</version>

我想手动增加版本,即重复构建会产生相同的版本,直到我手动增加

I want to increment version manually, that it - repetitive build would produce same version until I increment it manually.

如何实现仍然具有单个核子?

How can I achieve that still having single nuspec?

我可以在打包任务中调整打包版本吗?像这样:

Can I adjust package version in the pack tasks like this:

Release: $(PackageVersion) = $(PackageVersion)
Pre-release: $(PackageVersion) = $(PackageVersion)-beta

或类似的东西。

推荐答案

要由nuspec生成两个包,您可以使用两个NuGet任务(NuGet自定义而不是NuGet包):

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

命令:自定义

命令和参数:

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



NuGet任务:



命令:自定义

NuGet task:

Command: custom

命令和参数:

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






如果将 $(Build.BuildNumber)设置为 MyProject-Daily_1.0.94这样的格式.0 要将nuget软件包的版本添加为 1.0.94.0 时,可以在构建定义中定义变量并设置值通过剪切 $(Build.BuildNumber)的子字符串。详细步骤如下:


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:

变量标签中,添加变量(例如 version )具有任意值(例如 temp )。

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

在带有设置的NuGet任务之前添加 PowerShell任务

Add a PowerShell Task before NuGet tasks with the settings,

类型:内嵌脚本

内嵌脚本:

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

然后在NuGet自定义任务中使用 $(version)替换 $(Build.BuildNumber) for -version 选项。例如 nuget pack -version $(version)

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

这篇关于如何从VSTS中的一个nuspec生成发布和预发布软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆