Update Version Variables And PackageThe 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. ImportantThe task is in beta stage Git: Tested with Azure DevOps git. Agent Specification: Tested on Windows and Linux DocumentationTo 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: Pre configure the tasksVariables to create:Major example value = 0 Minor example value = 0 Patch example value = 1 VersionTag example value = 0.0.1 Configure Allow scripts to access the OAuth token:Security:Find the user running the pipeline: First we must enter the "name of your project" and then Build Service For example: "Project1 Build Service"
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
Version = Major + Minor + Patch
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 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 projectsWe use the Replace Tokens task. Before build the solution: replace these values with the value of variable Assembly and AssemblyFile To version your nuget packagesTo replace version in azure DevOps custom task projectThese 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 |