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?
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.
Move the version info into a separate file (e.g. AssemblyVersion.cs) in your solution's root directory. Then remove the version info from each project's AssemblyInfo.cs file and add the shared AssemblyVersion file to each project as a link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With