Skip to content
Imre Pühvel edited this page Mar 12, 2015 · 2 revisions

How it works

Nuget installer injects a special MsBuild task to build process to generate some extra code on each build. This task is added to project file and hence stored within source control with your code. So once set up the given versioning logic and chosen configuration is automatically distributed to all team members working on the code base. Moreover, all settings are always in sync across team and their history tracked along with code.

Versioning info is to be stored in target projects within the following attributes: FileVersionAttribute, InformationalVersionAttribute and ConfigurationAttribute. Hence, versioning info added by this tool does not require any dlls to be deployed with your application. Everything happens at build-time. Versioning info can be read at runtime using standard .Net reflection code.

Requirements

Provided you have already installed the tool to your target project, you are typically set to go.

In case of problems the underlying requirements are:

  • .Net Framework 4.0+ should be installed (usually present with VS)
  • Properties/AssemblyInfo.cs should exist and contain AssemblyVersion information (this is so by default in Visual Studio projects)
  • Properties/Nortal.Utilities.AssemblyVersioning.MsBuildTask.props files should be present (it is created automatically by nuget installer).

Detailed process on build

Nuget installer adds a MSBuild target file to hook to build process and generates some extra code on each build. Steps performed:

  • looks up what to generate from Properties/Nortal.Utilities.AssemblyVersioning.MsBuildTask.props
  • reads base version information from AssemblyVersion.cs
  • generates the extra code file AssemblyInformationalVersion.gen.cs with extra versioning information
  • includes the generated file on build
  • removes the generated file from project after build

For transparency the generated file is not deleted during build process but retained in Properties folder. It can be examined to verify generated information or for troubleshooting. This file can safely be ignored for version control or deleted at will. It will be always recreated from scratch on next build.

Clone this wiki locally