I'm trying to build a dotnet core application via Azure DevOps. I want my assemblies to be versioned with the build number.
In .csproj file:
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<Version>0.0.1</Version>
</PropertyGroup>
The yaml build pipeline contains:
trigger:
branches:
include:
- master
pool:
name: 'Hosted Windows 2019 with VS2019'
#vmImage: 'ubuntu-latest'
variables:
buildConfiguration: 'Release'
Version.Revision: $[counter(format('{0:yyyyMMdd}', pipeline.startTime), 0)]
VersionMajor: 0
VersionMinor: 1
name: '$(VersionMajor).$(VersionMinor).$(Date:yy)$(DayOfYear).$(Version.Revision)'
steps:
- task: DotNetCoreInstaller@0
inputs:
version: '2.2.300'
- script: dotnet build --configuration Release /p:Version=$(Build.BuildNumber)
displayName: 'dotnet build $(buildConfiguration) $(Build.BuildNumber)'
In the Azure Devops build log the command seems to pick up the correct version:
dotnet build --configuration Release /p:Version=0.1.19185.10
But when I download the artifacts and verify the dlls they still contain version number 0.0.1
Executing this command locally does add the version number in the dll. So, why is the version not added via Azure DevOps?