There are a few options available when configuring your nuget package versioning scheme in your build pipeline.
Let’s explore the differences:
Off
The package version is not changed during the build. Instead the version provided in your csproj file is used.
- task: DotNetCoreCLI@2 | |
inputs: | |
command: 'pack' | |
packagesToPack: '**/*.csproj' | |
versioningScheme: 'off' |
Use the date and time
When selecting the ‘Use the date and time’ option, it is up to you to provide a Major, Minor and Patch version number. The datetime will be used as the prerelease label:
$(Major).$(Minor).$(Patch).$(date:yyyyMMdd)
- task: DotNetCoreCLI@2 | |
inputs: | |
command: 'pack' | |
packagesToPack: '**/*.csproj' | |
versioningScheme: 'byPrereleaseNumber' | |
majorVersion: '1' | |
minorVersion: '0' | |
patchVersion: '0' |
Use an environment variable
A third option is to use an environment variable. The environment variable should contain the version number that you want to use and should be in a valid format.
- task: DotNetCoreCLI@2 | |
inputs: | |
command: 'pack' | |
packagesToPack: '**/*.csproj' | |
versioningScheme: 'byEnvVar' | |
versionEnvVar: 'PACKAGE_VERSION' |
Remark: You should enter the name of the environment variable without $, $env, or %.
Use the build number
A last option is to use the build number. This will use the build number to version the package.
- task: DotNetCoreCLI@2 | |
inputs: | |
command: 'pack' | |
packagesToPack: '**/*.csproj' | |
versioningScheme: 'byBuildNumber' |
Remark: This will change the build number format to a version compatible definition: '$(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)'.
No comments:
Post a Comment