0

Before, I was displaying my product version with :

@string.Format("v{0}", ViewContext.Controller.GetType().Assembly.GetName().Version)

where the version was stored in the AssemblyInfo.cs like so :

[assembly: AssemblyVersion("2.2.1.0")]

and the result was "v2.2.1"

Now, I'm using CI/CD with Azure DevOps and I'd like to display the $(Release.ReleaseName) instead of the AssemblyVersion.

How can I do that? Is it possible?

madhatterx
  • 53
  • 8

2 Answers2

0

tag\update the assemblyinfo.cs with the $(release.releasename) variable value during the build. there is a special task for that, as far as I recall, something like this: https://marketplace.visualstudio.com/items?itemName=richardfennellBM.BM-VSTS-Versioning-Task

or just create a script that would do that for you

4c74356b41
  • 69,186
  • 6
  • 100
  • 141
  • Thank you for you suggestion, I'll download the extension and see what if offers. However, I let the subject unresolved until I've tested it or someone else suggests something more Microsoft-ish :p – madhatterx Nov 19 '19 at 15:18
0

Display Azure DevOps pipeline variables inside my code

AFAIK, there is no out of box to way to update the AssemblyVersion by the value the $(Release.ReleaseName).

As workaround, just like 4c74356b41 pointed out, you could use the Assembly Info task to update the AssemblyInfo.cs:

enter image description here

enter image description here

Note:

  • Since you need use this task in the release pipeline, you need change the default value in the Source folder to $(System.DefaultWorkingDirectory).
  • The Release name format need match the Semantic Versioning Specification (SemVer)

Hope this helps.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135