I want to change the assembly version number of a C# project at build time by passing it as a property on the MSBuild command line.
AssemblyInfo Task will modify the assembly version inside a AssemblyInfo.cs before compiling. This is nearly what I want. The problem is I don't want AssemblyInfo.cs to be changed because of source control issues. I don't want all these AssemplyInfo.cs files to show as being modified and needing to be checked in every time we do a build.
What I would like is a "thing" that changes the assembly version number after compilation - perhaps using a post build weaving task. Does such a "thing" already exist somewhere either as open source or a retail product? If not, can someone point me to documentation for writing a post build weaver task?
Since the AssemblyVersion
does get cooked into your assembly at compile time, the AssemblyInfo.cs
file with the current build number does belong in source control.
If your issue with storing this in source control is because you don't want tons of files that need to be updated, try this.
You can establish links in your solution so that all projects point to a single file, e.g. SharedAssemblyInfo.cs
. Here is a page describing this process:
http://blogs.msdn.com/b/jjameson/archive/2009/04/03/shared-assembly-info-in-visual-studio-projects.aspx
You can use the SharedAssemblyInfo.cs
file using the AssemblyInfo task that you know about already, and this will be the only file that needs to be checked back into source control.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With