Reputation: 2266
I made a nugget package for a dotnet standard project via CI/CD azure pipeline. I used the following yml to define the version.
variables:
buildConfiguration: 'Release'
Major: '1'
Minor: '1'
Patch: $[counter(variables['minor'], 1)]
...
...
- task: DotNetCoreCLI@2
displayName: 'Preparing build artifacts'
inputs:
command: pack
publishWebProjects: false
arguments: ' --configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)'
packagesToPack: '**/Package.csproj'
versioningScheme: byPrereleaseNumber
majorVersion: '$(Major)'
minorVersion: '$(Minor)'
patchVersion: '$(Patch)'
The package builds correctly, and I can publish it via my release pipeline. The issue is that, the package is build with a version suffix constantly attached to it. For example:
Package 1.0.0-CI-20201203-170521
And the suffix changes, since it is derived from the actual time by azure devops. I want to remove this suffix from my version naming. I don't need it Since my patch version already increments well, and all my packages would have a unique version even without it.
I tried adding
<VersionSuffix>MySuffix</VersionSuffix>
in my csproj, but it did not change anything. I tried several methods of naming a package's version, but nothing worked. Please does anyone have a solution ?
Upvotes: 0
Views: 974
Reputation: 40603
You can use byEnvVar
to achieve your versioning
- pwsh: |
$packageVersion = '$(Major).$(Minor).$(Patch)'
Write-Host "##vso[task.setvariable variable=PackageVersion;]$packageVersion"
- task: DotNetCoreCLI@2
displayName: 'Preparing build artifacts'
inputs:
command: pack
publishWebProjects: false
arguments: ' --configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)'
packagesToPack: '**/Package.csproj'
versioningScheme: byEnvVar
versionEnvVar: 'PACKAGEVERSION'
otherwise if you select versioning you are forced to use some predefined formats:
Upvotes: 1