Have 2 files, one for static stuff and one for the auto generated bits.
The pattern I usually apply is to have an SolutionInfo.cs
that's shared between projects and a AssemblyInfo.cs
per project which are unique per project.
An example folder structure could be
src
| Solution.sln
| SolutionInfo.cs
|
\--- Project
| Project.csproj
|
\---Properties
AssemblyInfo.cs
And basically your csproj file would instead of:
<Compile Include="Properties\AssemblyInfo.cs" />
Be something like:
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="..\SolutionInfo.cs">
<Link>Properties\SolutionInfo.cs</Link>
</Compile>
This way you keep any manual edits to your AssemblyInfo.cs
and can safely auto generate without risk of overwriting that info.
This also lets you share things like version / copyright / company between projects in a solution.
The Cake build script part of this would look something like this:
Task("SolutionInfo")
.IsDependentOn("Clean")
.IsDependentOn("Restore")
.Does(() =>
{
var file = "./src/SolutionInfo.cs";
CreateAssemblyInfo(file, assemblyInfo);
});