tfs - Nuget 包版本控制和从 CI 升级到生产 Nuget 源

标签 tfs continuous-integration nuget proget

技术:

Proget – Nuget 包管理服务器

TFS – 本地 2017 更新 1

问题: 当从 TFS 版本重新发布构建时,要重新打包已经进入我的 Proget 开发源的 CI Nuget 包,似乎没有办法获得自动 Semantic versioning 。 关于在 Nuget 打包程序设置中设置版本的帮助对话框如下所示。

Use Date and Time If you choose 'Use the date and time', this will generate a SemVer-compliant version formatted as X.Y.Z-ci-datetime where you choose X, Y, and Z.

Use an Environment Variable If you choose 'Use an environment variable', you must select an environment variable and ensure it contains the version number you want to use.

Use the Build Number If you choose 'Use the build number', this will use the build number to version you package. Note: Under General set the build format to be '$(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)

enter image description here

我希望能够重新发布一个 Nuget 包,该包已从 TFS 中的 CI 构建转移到我的 Proget 开发源,再转移到我的生产 Proget 源中。 Microsoft 有一篇关于 Versioning NuGet packages in a continuous delivery world 的精彩文章。在那篇文章中,他们回避了这样一个事实:他们正在做类似的事情,但他们没有提供任何关于如何实现这一目标的真正方向。

问题:

如何配置 Nuget 打包器,以便在创建包时输入构建变量?或者有没有一种方法可以设置主要版本并且每次只进行次要增量?其他人如何处理软件包从开发到生产的推广?

已尝试以下操作:

尝试将 $(Version) 作为构建和发布变量,但它似乎不起作用。包裹上贴有日期标签。此外,这似乎只在 TFS 的“构建”部分中真正起作用,其中模态窗口包含一个可以修改此值的位置。

尝试使用日期和时间方法,它将 CI 粘贴到内部版本号中。这几乎正​​是我们想要的减去 CI 定义的结果。因为它会自动插入 CI,所以这不适合生产。

关闭它,它会从 Nuspec 中提取版本,但这会假设在您的 CI 构建中,在推送最后一个发行版本后,您总是将版本号增加到比当前版本号大 1。这是因为 nuspec 位于您通过 TFS 发布链重新发布的构建文件中。至少可以说令人困惑。

使用设置为 $(BuildDefinitionName) 的内部版本号$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r) 我想要的是 $(Major) .$(次要).$(补丁)。尝试使用版本 1.0.0 的 $(Version)$ 会得到一个名为 的文件,其输出为 2017.11.3.1,似乎忽略了 $(Version) 变量。

最佳答案

不确定我是否完全明白你的意思,似乎你想在 TFS 上的 ci 进程之后创建一个语义版本化的 nupkg。

通常,nupkg 应如 MSVersioningSample 所示:1.0.8-ci-20171106-156033.nupkg

但是,您想重命名 nupgk 并将其作为发布版本重新发布到 nuget 服务器,只需 MSVersioningSample: 1.0.8.nupkg 与 $(Major).$(Minor).$( 相同补丁)。

您需要在构建代理中编辑NuGetPackager.ps1,更改$VersionRegex值,详细信息您可以查看此问题中的答案:How do I get TFS 2015 to parse 3 digit versioning for NuGet packaging

还可以尝试使用一些第三方扩展来处理 TFS 构建、发布任务、nuget 包中的语义版本控制,供您引用的示例:Semantic Versioning Build and Release Tasks

此外,请注意:Semantic Versioning 2.0.0 仅支持 NuGet 4.3.0+ 和 Visual Studio 2017 版本 15.3+。

关于tfs - Nuget 包版本控制和从 CI 升级到生产 Nuget 源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47104666/

相关文章:

linux - 让 Jenkins Job 运行 Puppet list

c++ - 为什么我可以在本地使用 CMake 提供的模块(特别是 CMakeDependentOption.cmake),但不能在 CI 或 Docker 上使用?

visual-studio-2008 - JSON.NET Visual Studio 2008 和 .NET 3.5 Compact Framework

visual-studio-2012 - 由于访问被拒绝错误,Nuget-update 不会安装

c# - NUnit3 测试不在 TFS 构建上运行

tfs - TFS 2012 中的个人资料图像

tfs - 获取错误 TF277003 : Cannot add more than one upgrade process template for team project

tfs - TFS2015新安装,503服务不可用

ruby-on-rails - 作为持续集成构建周期的一部分,如何对 Rails 应用程序进行性能测试?

nuget - 什么是 nuget props 文件,它的用途是什么?