1

I am trying gitversion /output buildserver in both powershell and command prompt and neither modify the environment variables with GitVersion.SemVer (for example). How can I use it in a script?

4

1 回答 1

1

根据文档

默认情况下,GitVersion 返回一个 json 对象到标准输出,其中包含 GitVersion 生成的所有变量。

因此,如果您想将其作为独立脚本的一部分而不是构建任务运行,只需从 stdout 获取 json 输出并将其转换为对象:

$GitVersion = gitversion |ConvertFrom-Json
$GitVersion.SemVer 
于 2017-04-20T19:37:34.473 回答