在 AppVeyor 支持人员的帮助下,我得到了它的工作。
1733-how-to-call-the-assemblyversion-patch-from-the-build-script
我必须使用 appveyor.yml 中的 init 部分。我为 UpdateBuild - 版本使用了单独的 cmd 行(我在使用 qoutes 时遇到了一些问题)。
init:
- cmd: "set appVeyorBuildVersion=%appveyor_build_version%\necho appVeyorBuildVersion:%appVeyorBuildVersion% \n\nset branch=%APPVEYOR_REPO_BRANCH%\necho branch:%branch%\n\nset gitVersion=%branch:~-3%\necho gitversion:%gitVersion%\n\nset newVersion=%gitVersion%.%APPVEYOR_BUILD_NUMBER%\necho %newVersion%\n\n"
- cmd: appveyor UpdateBuild -Version "%newVersion%"
assembly_info:
patch: true
file: '**\AssemblyInfo.*'
assembly_version: '{version}'
assembly_file_version: '{version}'
assembly_informational_version: '{version}'
build_script:
- cmd: "echo Building version:%appveyor_build_version%"
- cmd: "nuget restore\nmsbuild MySolution.sln /t:build /p:Configuration=Release"
命令行部分(可读性更好):
echo repo branch:%APPVEYOR_REPO_BRANCH%
set branch=%APPVEYOR_REPO_BRANCH%
echo branch:%branch%
set gitVersion=%branch:~-4%
echo gitversion:%gitVersion%
set newVersion=%gitVersion%.%APPVEYOR_BUILD_NUMBER%
echo %newVersion%
appveyor UpdateBuild -Version "%newVersion%"