本文介绍了Build.SourceVersion在VSO vNext Build中为空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio Online(不是XAML构建定义)中使用新的可编写脚本的构建功能,并且我试图让构建版本号包含使用Build Number Format的目标存储库的最新Git Commit ID。 / p>

我使用以下内部版本号格式:

  $(MajorVersion )。$(MinorVersion)。$(BuildId)。$(SourceVersion)

版本号为 1.0.1234。 - 即SourceVersion值为空,这会在构建队列时导致VSO中的错误。我也尝试通过在 Build。前添加相同结果来限定变量。为了测试,我已将内部版本号更改为以下格式:

  $(MajorVersion)。$(MinorVersion)。$( BuildId)。$(SourceBranch)

正确的结果是 1.0 .1234.refs_heads_master



我一直使用



这是我看到的错误显式指定一个Git CommitId:

lockquote
400:内部版本号格式字符串
$(MajorVersion)。$(MinorVersion)。$ (BuildId)。$(SourceVersion)生成
uild编号0.1.1。其中包含无效字符,太长
或以'。'结尾。内部版本号的最大长度为255
个字符。不允许的字符包括'''','/',':',
'<','>','\','|','?','@'和' *'。



解决方案

我可以使用 .SourceVersion),但只有当构建在提交时自动触发(在持续集成上),只有当我手动排队时,结果才是空的:





我使用以下内部版本号格式:


$ b $($ Build $)$(BuildDefinitionName)_ $(date:yyyyMMdd)_ $(Build.BuildId)。$(Build.SourceVersion)$(rev:.r)


I am using the new scriptable build features in Visual Studio Online (not the XAML build definitions), and I am trying to have the build version number include the latest Git Commit ID of the target repository using the Build Number Format.

I am using the following build number format:

$(MajorVersion).$(MinorVersion).$(BuildId).$(SourceVersion)

Which results in a generated version number of 1.0.1234. - i.e. the SourceVersion value is blank, which causes an error in VSO when queueing a build. I have also tried qualifying the variable by prefixing it with Build. with the same result. To test, I have changed the build number to the following format:

$(MajorVersion).$(MinorVersion).$(BuildId).$(SourceBranch)

This correctly results in a value of 1.0.1234.refs_heads_master

I have been using the Predefined Variables reference and Build.SourceVersion is listed as a Global Variable.

Am I doing something wrong, have I encountered a bug or is this by design and not available at the time the build is queued? If this is by design, is there any way to automatically include the short Git Commit ID in the Build Number Format?

This is where I set the build number format in VSO:

This is the error I see when I don't explicitly specify a Git CommitId:

解决方案

I was able to use $(Build.SourceVersion), but only when builds were triggered automatically on commit (on Continuous integration). It turns out to be empty only if I queue it manually:

I'm using the following Build number format:

$(BuildDefinitionName)_$(date:yyyyMMdd)_$(Build.BuildId).$(Build.SourceVersion)$(rev:.r)

这篇关于Build.SourceVersion在VSO vNext Build中为空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 17:01