Tuesday, February 06, 2007

As your solution grows, the number of assemblies you have will undoubtedly grow too. Updating the version numbers of all those assemblies by their projects AssemblyInfo.cs files can be a hassle. However, there is a way to change the version in just one file, but have that change affect all project assemblies!

By using a “link” file in your projects, you can include a file from a shared location that contains only the version information.

  • Add a new file named VersionInfo.cs
  • Add to this file only the version information from an existing AssemblyInfo.cs file
    Screenshot showing sample VersionInfo.cs<
  • Add VersionInfo.cs as a solution item

Now, for each project that you wish to include this version information:

  • Select “Add Existing Item…” on the project menu
  • Browse to VersionInfo.cs file
  • Click the down arrow on the “Add” button and choose “Add as Link”
    Screenshot showing 'Add As Link' button
    The file will have the shortcut icon when you look at the project files.
    Screenshot showing VersionInfo.cs in soultion
  • Remove any version information from existing AssemblyInfo.cs

When then assembly is built it will essentially have the combined attribute values from the AssemblyInfo.cs and VersionInfo.cs file.

Now you only have to change the version in one place and all projects will get it :-)

Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):