Many of the questions on StackOverflow or other blogs indicate how to use the Jenkins build number and the change assembly version plugin to set the AssemblyVersion in the AssemblyInfo.cs file.
But I'm trying to do the opposite - setting the jenkins build version to the version from AssemblyInfo.cs? Obviously, I would do this AFTER the source code has been pulled down.
Why do I want to do this? Reason: I'd like to synchronize the following four 'components'
My AssemblyInfo.cs, e.g. [assembly: AssemblyVersion("2.10.*")] is my "source of truth" for major.minor versioning
At time of build, I'd update the version to, e.g. 2.10.73 where the 73 is from ${BUILDS_ALL_TIME}
We publish our code to our internal nuget server, so I'd like the version of the nuget package to be, e.g. 2.10.73
I plan to tag/label our source control with the name of the Jenkins Build
So I'd like my jenkins build name to be, e.g. MyProject.2.10.73
Can I do this? Namely, I'd like the major.minor version to be set in my AssemblyInfo.cs which is in source control.
Thanks!
Thanks to Suresh for pointing me in the right direction.
I ended up 1) Using the EnvInject Plugin (as a build action)
https://wiki.jenkins.io/display/JENKINS/EnvInject+Plugin
2) Wrote my own PowerShell script to read my AssemblyInfo.cs file and output my environment properties see this post
https://i-script-stuff.electric-horizons.com/environment-inject-variable-with-powershell-and-jenkins/
3) Used the Build Name Setter Plugin to then change the name after the build
https://wiki.jenkins.io/display/JENKINS/Build+Name+Setter+Plugin