Blog of Web Developer Garry Pilkington

(ASP.Net, C#, AngularJs, JavaScript, HTML5 & UWP)

Minification and Concatination of JavaScript and CSS FilesVersioning Combined Files Using SubversionVersioning Combined Files Using Mercurial – this post In this post I explore versioning of the build dll and CSS and JavaScript files to match that produced from Mercurial to help improve web site performance. I have worked on a project recently where there was a need to version the system (library dll, css and javascript files) by date and Mercurial revision number. This was in the format:- 0.12.524.407 {major}.{year}.{month}{date}.{mercurial revision} Each time there is an internal build using the CI server, it would label the files using this format. When it came time to do a major release, it became v1.{year}.{month}{date}.{mercurial revision}, with each public release having a major version increment. Also as a requirement, each assembly also had to have a new GUID on each build. So like in previous posts, we need to edit the csproj file, and add a couple of Default targets.Right below the closing tag of the entire project we add our two targets, the first is to get the Mercurial revision number. We first need to import the tasks for MSBuild which can be downloaded from https://msbuildhg.codeplex.com/With the main Mercurial files being located at c:\TortoiseHg To get a valid GUID we need to escape from the csproj markup and call some c# code which we put in a property group for later reference.Now we add in our target for generating the GUID.So this will give use an AssemblyInfo.cs file like this just prior to calling the Build task:-Therefore giving us the correct version for the assembly. This can be referenced within your project whether web or Windows based like this:-As mentioned in previous posts in this series, you can label css and javascript files using this version number and the GetAssemblyIdentity task from the main MSBuild task library build into the .Net framework.Then use this to write out the files:-