How do I sync versions between Visual C# projects?

build, c#, project, synchronization, version

Solution

What we do is very similar to Chris' answer:

We have a project called `ProductVersion`, where "Product" is actually the product name. Inside is a static class called `VersionInformation` which contains constant strings including one called `ProductVersion`, which is where we actually set the version information.

Then in each project's `AssemblyInfo.cs` file, our `AssemblyVersion` line looks like this:

[assembly: AssemblyVersion(Company.Product.VersionInformation.ProductVersion)]

In your case, since both the client and server reference the base project, you could just include something similar in the base project instead of creating a separate project.

Problem

I have three projects in my solution: a base project, and a client and server that reference the base. What I'd like to do is be able to set the base project file's assembly version, and have that automatically propagate to the server and client so their versions always match. Ideally, this would be a pre-build step to sync them. Does anyone know if this is possible or how I'd go about doing so?

Original source