[英]Azure DevOps .NET Core build and publish doesn't keep given application version
I've an ASP.NET Core application I'm publishing on a dedicated server via Azure DevOps build/release pipelines.我有一个 ASP.NET Core 应用程序,我通过 Azure DevOps 构建/发布管道在专用服务器上发布。
I'm managing the application version number with the GitVersion task ( gittools.gitversion.gitversion-task.GitVersion@4
) in the YAML build.我正在使用 YAML 构建中的 GitVersion 任务 ( gittools.gitversion.gitversion-task.GitVersion@4
) 管理应用程序版本号。
The build step is something like:构建步骤类似于:
- task: DotNetCoreCLI@2
displayName: 'dotnet build'
inputs:
command: custom
custom: build
workingDirectory: src/MyAppProjectFolder
arguments: '-p:Version=$(GitVersion.FullSemVer)'
And is correctly generating the .exe with the given FullSemVer (I'm inspecting the Azure agent work folder)并使用给定的 FullSemVer 正确生成 .exe(我正在检查 Azure 代理工作文件夹)
Then I've the publish step:然后我有发布步骤:
- task: DotNetCoreCLI@2
displayName: 'dotnet publish'
inputs:
command: publish
publishWebProjects: false
arguments: '--output $(build.artifactstagingdirectory) --no-restore --no-build'
workingDirectory: src/MyAppProjectFolder
For some reason the same .exe i found in the C:\\agent_work\\1\\a\\a.zip created by the publish DOESN'T have the correct version number, but the generic 1.0.0.出于某种原因,我在发布创建的 C:\\agent_work\\1\\a\\a.zip 中找到的相同 .exe 没有正确的版本号,但通用 1.0.0.0.exe 没有正确的版本号。
If I "emulate" the pipelines manually on the same server (with dotnet build
and dotnet publish
manually via powershell, same parameters) everything works as expected.如果我在同一台服务器上手动“模拟”管道(使用dotnet build
和dotnet publish
通过 powershell 手动dotnet publish
,相同的参数)一切都按预期工作。
What's going on?这是怎么回事? Is there a way to ensure the application to keep the $(GitVersion.FullSemVer) version?有没有办法确保应用程序保留 $(GitVersion.FullSemVer) 版本?
Note : I had to add注意:我必须添加
- task: UseDotNet@2
displayName: 'Use .Net Core sdk 2.1.x'
inputs:
packageType: sdk
version: 2.1.x
installationPath: $(Agent.ToolsDirectory)/dotnet
includePreviewVersions: true
in front of each NET Core task, as explained here , after the agents have been updated to .NET Core 3.0 (before these builds worked well).在每个网络核心任务面前,作为解释在这里,代理商已经更新到.NET 3.0的核心后(之前这些构建行之有效)。
尝试将-p:Version=$(GitVersion.FullSemVer)
到发布步骤的参数中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.