Update version info with MSBuild (after binaries compilation)
-
21-09-2019 - |
Question
I want to make a target in my MSBuild script that:
- Fetch SVN revision/datetime from sources folder ('svn info' command)
- Update VERSIONINFO resource from .EXEs and .DLLs generated by 'build' target
There is something ready to accomplish this? I'm asking just before reinvent another wheel...
I'm giving a look into http://msbuildextensionpack.codeplex.com
Solution
MSBuild Community Tasks Project is your friend. Check their "SvnInfo" task.
Also, Daniel Doubrovkine's ResourceLib is an excellent piece of work and can avoid you lots of headaches when trying to untangle the VERSIONINFO creation mess (been there, done that...)
OTHER TIPS
Much easier to do this before compilation by writing an AssemblyInfo file (or any file with assembly attributes) thats included in your projects.
Example of writing this in powershell found here: https://github.com/craigbeck/rhino-esb/blob/master/psake_ext.ps1#L7-46
One caveat -- the versions in .net are not just any string but ushort
s which means they have a max of 65535 (see docs here). If you use the svn revision (as we did at one point) your build will break once it exceeds that magic number.
Why would you be trying to do this after compilation?