Keeping versions of .NET assemblies in sync
Hi,
a couple of days ago someone asked me how to keep several assemblies part of the same solution in sync. Some time ago I used the following technique:
Create a new assembly, for example called Build, with a class called VersionInf
namespace BestPractices.Build
{
public class VersionInfo
{
public const string Version = "1.0.0.0";
public const string Company = "SomeCompany";
public const string Product = "MyQualityProduct";
public const bool DelaySign = false;
public const string KeyFile = @"c:\SN.snk";
}
}
After building this assembly you can use it in other assemblies' AssemblyInfo like this (removed all comments to save space):
using System.Reflection;
using System.Runtime.CompilerServices;
using BestPractices.Build;
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany(VersionInfo.Company)]
[assembly: AssemblyProduct(VersionInfo.Product)]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion(VersionInfo.Version)]
[assembly: AssemblyDelaySign(VersionInfo.DelaySign)]
[assembly: AssemblyKeyFile(VersionInfo.KeyFile)]
[assembly: AssemblyKeyName("")]
Because constants are copied to the dependent assembly you actually only need the build assembly at-compile time.
Now each assembly will have the same version, keyfile, etc... If you want to update the version (like in a daily-build scenario) you only have to update the VersionInfo.cs file.