I'm building a project through Azure Pipelines. I'm not managing any version settings in VS -- I'm setting the version with dotnet build
.
- task: DotNetCoreCLI@2
displayName: 'DotNet Build'
inputs:
command: build
arguments: '--configuration $(BuildConfiguration) /p:Version=$(GitVersion.SemVer)'
projects: $(ProjectPath)
As you can see, I set the Version using a GitVersion variable. In the resulting .dll, the File Version
shows the version correctly. I expected the Product Version
to show the same thing but it seems to include some additional weird guid or something. Does anyone know where that comes from and how to keep it from being appended?
From your screenshot, the long string should be the commit hash.
The issue is from the .net8 SDK. It will include the commit SHA in the informational version automatically.
I can reproduce the same issue.
By default, Azure Pipelines will use .net8 to build the project now.
To solve this issue, you can add the <IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
to your csproj file.
For example:
<Project>
<PropertyGroup>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>
</Project>
Or you can add the argument to your build task: /p:IncludeSourceRevisionInInformationalVersion=false
For example:
--configuration $(BuildConfiguration) /p:Version=$(GitVersion.SemVer) /p:IncludeSourceRevisionInInformationalVersion=false
Or you can downgrade the .net version with the task: Use .NET Core
For more detailed info, you can refer to this ticket: Git commit ID included in assembly ProductVersion field when building with sdk 8