- #AUTOMATIC VERSION VISUAL STUDIO MARKETPLACE INSTALL#
- #AUTOMATIC VERSION VISUAL STUDIO MARKETPLACE CODE#
Var buildDateTime = new DateTime(fileVersion.Major, fileVersion.Minor/100, fileVersion.Minor%100, fileVersion.Build/100, fileVersion.Build%100, fileVersion.Revision)
Version fileVersion = new Version(fileVersionString)
Var fileVersionString = (assembly.Location).FileVersion Include the resulting VersionInfo.cs file (Properties subfolder) into your projectĬode to get Date back (years down to seconds): var version = assembly.GetName().Version Pre-Build-Event: echo > $(ProjectDir)Properties\VersionInfo.cs To get incrementing (DateTime) information into the AssemblyFileVersion property which has the advantage of not breaking any dependencies.īuilding on Boog's solution (did not work for me, maybe because of VS2008?), you can use a combination of a pre-build event generating a file, adding that file (including its version properties) and then using a way to read out those values again. You must include this file in your project and build with it. This will generate a VersionInfo.cs file with an Assembly attribute for AssemblyFileVersion where the version follows the schema of YY.MM.DD.TTTT with the build date. I've accomplished this by specifying AssemblyVersion in the AssemblyInfo.cs and generating a VersionInfo.cs in MSBuild like this, Instead, I want to have a hard-coded AssemblyVersion but an auto-incrementing AssemblyFileVersion. However, I can not use the VS 6.0.* AssemblyVersion trick as it auto-increments build numbers each day and breaks compatibility with Assemblies that use an older build number.
#AUTOMATIC VERSION VISUAL STUDIO MARKETPLACE CODE#
I am generating code and compiling to an Assembly and want to auto-increment version numbers.
#AUTOMATIC VERSION VISUAL STUDIO MARKETPLACE INSTALL#
I came up with a solution similar to Christians but without depending on the Community MSBuild tasks, this is not an option for me as I do not want to install these tasks for all of our developers. The different algorithms for changing the version components are described in $(MSBuildExtensionsPath)\MSBuildCommunityTasks\ and Version Properties. This file then has to be added to the project (via Add existing item), and the AssemblyVersion and AssemblyFileVersion lines have to be removed from AssemblyInfo.cs. It currently does not use the invariant culture.įor the third build on January 14th, 2010, this creates a VersionInfo.cs with this content: Note: Adapt the StartDate property to your locale. Just download their installer, install it, then adapt the following code and paste it after in your. Another option for changing version numbers in each build is to use the Version task of.