2016-08-31 29 views
0

當我把我的TFS 2015年建立的定義,就是創造一個NuGet包,我設定的內部版本號格式:如何獲取TFS 2015年來解析3位版本的的NuGet包裝

$(BuildDefinitionName)_$(Major).$(Minor)$(rev:.r)

其中major以及我定義的次要變量或變量。當我使用步驟「的NuGet打包」,我得到的錯誤:

Could not find version number data in BUILD_BUILDNUMBER.

當我用4個數字,我沒有得到這個錯誤。我如何使它與語義版本控制一起工作?

回答

0

如果你看看https://github.com/Microsoft/vsts-tasks/blob/master/Tasks/NugetPackager/NuGetPackager.ps1https://github.com/Microsoft/vsts-tasks/commit/233c112bc06b91964a559090b8acfd4452cdec0b

在此之前提交的正規表示法只是\d+\.\d+\.\d+\.\d+

if ($b_versionByBuild) 
{ 
    Write-Verbose "Autoversion: Getting version number from build" 
    ##Get Version from Build 
    # Regular expression pattern to find the version in the build number 
    # and then apply it to the assemblies 
    $VersionRegex = "\d+\.\d+\.\d+(?:\.\d+)?" 

支持3部分版本號從這次提交出來。所以也許你的TFS中有一個過時的任務代碼。

我剛剛檢查了我的前提TFS 2015.它無法解析3號碼版本。

+0

我使用TFS 2015年更新3。 – Antebios

1

我找到了解決辦法:

1)你需要讓你的生成代理機

2)導航到安裝生成代理那裏獲得。 對我來說 - > C:\ BuildAgent \ tasks \ NuGetPackager

3)你會看到文件夾的版本,所以進入最新的版本。

4)修改PowerShell腳本,NuGetPackager.ps1

Find --> $VersionRegex = "\d+.\d+.\d+.\d+"

And replace with --> $VersionRegex = "\d+.\d+.\d+.\d+|\d+.\d+.\d+"

5)然後保存腳本。

我在做的是修改正則表達式來說「在內部編號字符串中搜索模式#。#。#。#OR#。#。#」。而之前它只是在尋找「#。#。#。#」。

現在,當你完成你的構建,在TFS生成代理就能解析生成版本:

Set workingFolder to default: C:\BuildAgent\tasks\NuGetPackager\0.1.58

Executing the powershell script: C:\BuildAgent\tasks\NuGetPackager\0.1.58\NuGetPackager.ps1

Getting version number from build

BUILD_BUILDNUMBER: Planning.Domain.Library-CI_1.0.7

Version: 1.0.7

相關問題