I've got a rather large solution in Visual Studio. Is there a way to update the Major / Minor version numbers for all the assemblies in the solution in one go?
-
[Sharing assembly version across projects in a solution](https://weblogs.asp.net/ashishnjain/sharing-assembly-version-across-projects-in-a-solution) – Ozair Kafray Aug 19 '20 at 15:14
6 Answers
You can share an AssemblyInfo.cs file between all projects in the solution. This shared file should contain the version numbers. To share it, you must use Add Existing File in VS and select Add as Link in the file dialog. Every project has its private and the shared AssemblyInfo.cs. The private one still contains the non-Version attributes.
I've got a TeamCity setup, where I'm generating the shared file in each TeamCity build using the actual build version and it works beautifully.

- 2,265
- 1
- 16
- 15
-
8I tend to call the shared file "SolutionInfo.cs" also with things like copyright in it as well, and saved as a solution item for SCM with all projects linking to it equally. – Richard Apr 17 '09 at 09:32
-
-
That is so brilliantly simple (and brilliantly brilliant), and such a great habit to cultivate in general. Thank you. – GregRos Aug 08 '15 at 21:12
-
-
Excellent. Same solution explained in detail with screenshots: [Sharing assembly version across projects in a solution](https://weblogs.asp.net/ashishnjain/sharing-assembly-version-across-projects-in-a-solution) Just an added note. The assembly attributes defined in the common/shared file cannot be overwritten in project's assembly info file. If a certain project follows its own versioning, then it shall delink the common file and define all of the common attributes on its own. – Ozair Kafray Aug 19 '20 at 15:16
We have a single AssemblyInfoCommon.cs which has the version numbers, and is included in each project by reference. The other AssemblyInfo.cs files remain but only contain the assembly-specific information (title and description). So we only have one file to update for every C# project.

- 2,992
- 5
- 22
- 21
You can also have a public const string in one of your classes, that represents the build number, and use it in all your AssemblyInfo.cs for the different projects. Of course this would have to be in a project that are referenced by all the other projects, in order to work.
It is a good option, if you don't like the idea to reference the same AssemblyInfo.cs in all your projects.
Edit: Note! This also works when you use multiple languages (F# and C# in my case).
Search/Replace?
The version numbers are stored in text-files after all (AssemblyInfo.cs under the Properties folder for each project).

- 380,855
- 102
- 628
- 825
-
That would work if all the assemblies were at the same major/minor version. Unfortunately mine are all over the place :) – PaulB Apr 17 '09 at 09:02
-
Do you want to just increment them, or make them all the same? Because you can easily use a regular expression to find them all, even if they have different numbers. – Lasse V. Karlsen Apr 17 '09 at 09:09
-
1Here's one that would work: \\[assembly:\s+AssemblyVersion\\("\d+\.\d+\.\d+\.\d+"\\)\\] – Lasse V. Karlsen Apr 17 '09 at 09:10
There is a very useful utility I used some time ago on a project which required highly managed versioning:
http://www.codeproject.com/KB/macros/versioningcontrolledbuild.aspx
Also you can create some "core" assembly and add into each your assembly reference to "core" assembly. "core" assembly will constaint constant. In this case in each Assembly info file will be set asembly version from "core" constant. For example:
"core" assembly has file Ver.cs with constant: public const string Value = "0.0.0.99";
in each solution assembly info will: [assembly: AssemblyFileVersion(Ver.Value)]

- 1