Seems like t4 templates could help you. It's template generation engine. There are enough info about it which will be helpful.
I made a simple template which does what you want. It's just an example and probably you need to make some adjustments in the code:
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="Microsoft.CSharp.dll" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Text.RegularExpressions" #>
<#@ import namespace="System.Reflection" #>
<#@ output extension=".cs" #>
<#
var assemblyVersionRegex = new Regex(@"AssemblyVersion\(\""(?<version>(.*?))\""\)");
var pathBase = new FileInfo(Host.TemplateFile).DirectoryName;
var assemblyInfoPath = Path.Combine(pathBase, @"Properties\AssemblyInfo.cs");
var assemblyInfoSources = File.ReadAllText(assemblyInfoPath);
var match = assemblyVersionRegex.Match(assemblyInfoSources);
var version = match.Success
? match.Groups["version"].Value
: "unknow";
#>
public static class SomeAssemblyInfo
{
public const string Version = "<#= version #>";
}
So, it reads file AssemblyInfo.cs (or another if you want) get version from it and prepare class SomeAssemblyInfo :
public static class SomeAssemblyInfo
{
public const string Version = "1.0.0.0";
}
Last thing what you need to do is run this template on build. Here you can find how to do it.