我有一个正在通过Azure DevOps构建/发布管道在专用服务器上发布的ASP.NET Core应用程序。
我正在YAML版本中使用GitVersion任务(gittools.gitversion.gitversion-task.GitVersion@4
)管理应用程序版本号。
构建步骤类似于:
- task: DotNetCoreCLI@2
displayName: 'dotnet build'
inputs:
command: custom
custom: build
workingDirectory: src/MyAppProjectFolder
arguments: '-p:Version=$(GitVersion.FullSemVer)'
并且正在使用给定的FullSemVer正确生成.exe(我正在检查Azure代理工作文件夹)
然后执行发布步骤:
- task: DotNetCoreCLI@2
displayName: 'dotnet publish'
inputs:
command: publish
publishWebProjects: false
arguments: '--output $(build.artifactstagingdirectory) --no-restore --no-build'
workingDirectory: src/MyAppProjectFolder
由于某种原因,我在发布的C:\ agent_work \ 1 \ a \ a.zip中找到的同一个.exe没有正确的版本号,但是通用的1.0.0。
如果我在同一台服务器上手动“模拟”管道(通过Powershell手动使用dotnet build
和dotnet publish
,使用相同的参数,则一切正常。
发生了什么事?是否有办法确保应用程序保留$(GitVersion.FullSemVer)版本?
注:我必须添加
- task: UseDotNet@2
displayName: 'Use .Net Core sdk 2.1.x'
inputs:
packageType: sdk
version: 2.1.x
installationPath: $(Agent.ToolsDirectory)/dotnet
includePreviewVersions: true
在每个NET Core任务之前,如here所述,在将代理更新到.NET Core 3.0之后(在这些版本运行良好之前)。
将-p:Version=$(GitVersion.FullSemVer)
添加到要发布的参数中。