如何从VSTS中的一个nuspec生成发布和预发布软件包?

编程入门 行业动态 更新时间:2024-10-25 14:32:39
本文介绍了如何从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生成发布和预发布软件包?

本文发布于:2023-11-06 17:25:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1564322.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:软件包   VSTS   nuspec

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!