Allen Zhang Allen Zhang - 4 months ago 43
C# Question

How to use release date as assembly version for a .net project?

I know that the format of the assembly version is:

<major version>.<minor version>.<build number>.<revision>

Is there a way to make the version number the current date?

For example, if I compile the build today, the version number should look like this:


Where xxxxx is what you normally get if you set the assembly version to 1.0.0.*.

I googled around but didn't find an answer (not even a question) for this.


This can be done via MSBUILD. Here is a good description for it. You don't need a build server for this. You can call your custom MSBUILD target in the BeforeBuild Target of your project. For that open your csproj file with an editor and locate this section at the end of the file:

<!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  <Target Name="AfterBuild">