简体   繁体   English

Azure DevOps .NET Core 构建和发布不会保留给定的应用程序版本

[英]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 builddotnet 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.

相关问题 Azure DevOps - 如何发布 ASP.NET 应用程序 - Azure DevOps - How to Publish an ASP.NET application .net 核心单元测试项目未能在 Azure Devops 管道中构建 - .net core unit test project failing to build in Azure Devops pipeline azure devops使用asp.net core 2.2生成错误 - azure devops Build error with asp.net core 2.2 “RequestsDependencyWarning:urllib3 (1.26.12) 或 chardet (3.0.4) 与支持的版本不匹配!” 在 Azure DevOps - Azure 物联网边缘任务 - 构建 - "RequestsDependencyWarning: urllib3 (1.26.12) or chardet (3.0.4) doesn't match a supported version!" in Azure DevOps - Azure IoT Edge Task - build Azure Devops 管道问题 .NET Core Angular 应用程序 - Azure Devops Pipeline Question .NET Core Angular application Azure DevOps-发布任务构建失败 - Azure DevOps- Publish task build failed 将rc2 asp.net核心应用程序发布到Azure - Publish rc2 asp.net core application to Azure 无法从.net核心应用程序发布到Azure Web应用程序 - Unable to publish to Azure web app from a .net core application .net核心“ dotnet构建”命令不会在发生错误时中断Azure构建管道(bash) - .net core “dotnet build” command doesn't break Azure build pipeline (bash) on error build.artifactstaging 目录不存在 Azure Devops - build.artifactstagingdirectory doesn't exist Azure Devops
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM