When we have multiple projects in solution then every
project used to have different AssemblyInfo.cs file under
Project>Properties. So, if you want to change the version information for
release or any other attribute in AssemblyInfo.cs file then you might have
ended up doing same with every AssemblyInfo.cs of projects which is tedious and
time consuming. Here is the easy solution for this problem.
1. Create SharedAssemblyInfo.cs file as solution item
Go to any project and under Properties folder copy the AssemblyInfo.cs file and paste in solution folder. Now, rename the file as SharedAssemblyInfo.cs. Then, keep attributes which needs to be reflected as same across all projects and remove the remaining items. Make sure the remaining items exist in AssemblyInfo.cs file of every project. Basically, we segregate items from AssemblyInfo.cs into AssemblyInfo.cs and SharedAssemblyInfo.cs
Go to any project and under Properties folder copy the AssemblyInfo.cs file and paste in solution folder. Now, rename the file as SharedAssemblyInfo.cs. Then, keep attributes which needs to be reflected as same across all projects and remove the remaining items. Make sure the remaining items exist in AssemblyInfo.cs file of every project. Basically, we segregate items from AssemblyInfo.cs into AssemblyInfo.cs and SharedAssemblyInfo.cs
2. Update the solution’s AssemblyInfo file with required details that needs to be updated for every assemblies being built For every release or build, we need to update only
SharedAssemblyInfo.cs file under solution folder going forward.
3. Link SharedAssemblyInfo.cs file with every project
Right click on Project>Properties
and select Add > Existing Item
From the file selection dialog, get into solution folder and
select SharedAssemblyInfo.cs and then make sure to add the item as Link like
below (Add As Link). It is very
crucial to select Add As Link
otherwise (if Add would have been selected) visual studio would just create
copy of SharedAssemblyInfo.cs into
Project > Properties folder which cut the common update we want to make
across all projects.
Now, go ahead and build solution. Every project would
have same version number and other
attributes defined in SharedAssemblyInfo.cs file now.
No comments:
Post a Comment