Skip to content
| Marketplace
Sign in
Azure DevOps>Azure Pipelines>Update Version Variables And Package

Update Version Variables And Package

solucionespsg

solucionespsg.com.ar
|
3 installs
| (2) | Free
The UpdateVersionVariablesAndPackage VSTS task updates the variables that are used to name the artifact and is used to perform replacements in the application.

Update Version Variables And Package

The UpdateVersionVariablesAndPackage VSTS task updates the variables that are used to name the artifact and is used to perform replacements in the application.

This task is used to perform autoversioning of artifacts and application versions.

Important

The task is in beta stage

Git: Tested with Azure DevOps git.

Agent Specification: Tested on Windows and Linux

Documentation

To create an upgrade version, pipeline variables are used:

Major, Minor and Patch

As a summary, the final version is also stored in the variable:

VersionTag

These variables must be created before the first run:

alt tag

Pre configure the tasks

Variables to create:

Major example value = 0

Minor example value = 0

Patch example value = 1

VersionTag example value = 0.0.1

alt tag

Configure Allow scripts to access the OAuth token:

alt tag

Security:

alt tag

Find the user running the pipeline:

First we must enter the "name of your project" and then Build Service

For example: "Project1 Build Service"

alt tag Set "Edit build pipeline" in "Allow"

alt tag

Logic for versioning:

When a git push is made to the branch, the following procedure is performed:

If the git push does not have a tag

  • If the branch is "master" or "main": is updated first: Patch = Patch +1

Version = Major + Minor + Patch

  • If the branch is not "master" or "main": Version = Major + Minor + Patch +"-yyyyddMM-HHmmss"

If the git push has a tag in "x.b.c" format

The variables are updated: Major, Minor and Patch with the values "x", "b" and "c"

If the value "c" is not numeric Patch = Patch +1

  • If the branch is "test" or "qa" and value "c" is numeric: Version = "x.b.c-" + nameBranch

  • If the branch is "test" or "qa" and value "c" is not numeric Version = "x.b.c"

  • Other branches: Version = "x.b.c-yyyyddMM-HHmmss"

If the push has a tag but without "x.b.c" format

Update Patch = Patch +1

Version = Major + Minor + Patch

Variables that we can use after finishing the task:

Version: example output: "1.2.6-20231502-010322"

VersionShort: example output: "1.2.6"

NewMajor example output: "1"

NewMinor example output: "2"

NewPatch example output: "6"

Extra variables:

To perform overrides in .net frameworks projects:

Assembly: example output: "[assembly: AssemblyVersion("1.2.6")]"

AssemblyFile: example output: "[assembly: AssemblyFileVersion("1.2.6")]"

examples to replace variables:

For .Net Framework projects

We use the Replace Tokens task. Before build the solution:

alt tag

replace these values with the value of variable Assembly and AssemblyFile

alt tag

To version your nuget packages

alt tag

To replace version in azure DevOps custom task project

alt tag

alt tag

These are some examples among the thousands of uses that the autoversioning of our projects has.

Help to continue development.

If it helped you. You can help me:

https:// paypal.me/solucionespsg

  • Contact us
  • Jobs
  • Privacy
  • Terms of use
  • Trademarks
© 2023 Microsoft