AssemblyInfoTask is a MSBuild custom task published on GotDotNet.com. In fact, it is written by a MSBuild team member.
If you want to have assembly version number generated in Visual Studio style (such as 2.1.010529.12), you will love AssemblyInfoTask.
However, the version available from GotDotNet.com is out-of-date now and lacks of latest updates.
- The version number mask should be changed according to this post.
- If you are using SVN to manage the source code, you’d better follow this post. The “Subversion Fix” section is very useful.
- You should copy %ProgramFiles%\MSBuild\Microsoft\AssemblyInfoTask\Microsoft.VersionNumber.Targets to a local folder and make the above changes. Then set AssemblyMajorVersion and other properties in the *.targets file. I love this “one targets file one project” way.
- Do not change your projects like others tell you. Simply create a batch file named versioningbuild.bat and write
1 2 %windir%\Microsoft.NET\Framework\v2.0.50727\msbuild.exe (your.proj) /p:CustomAfterMicrosoftCommonTargets="(localfolder)\Microsoft.VersionNumber.Targets" @IF %ERRORLEVEL% NEQ 0 pause
localfolder with proper contents.
In this way, if you do not build using this batch file, AssemblyInfoTask will not execute. That’s why the version of my project only changes when I release it with versioningbuild.bat.
(Updated: Now AssemblyInfo Task is available from MSDN Code Gallery. Tip 2 is also useful if you use CodePlex TFS Command Line Client.)