This post explains the steps in setting up a professional versioning in a .NET solution.
Project versioning
In solutions, many projects can exist. It is important to structure the project so that when creating a release, all assemblies are set to the release version. This should be set as part of the release build, not manually or with some external build process tool etc. To do this, a GlobalAssemblyInfo class is used. This is linked to all projects but the file only exists once. To set the version number, only this file needs to be set and not every AssemblyInfo class in every project…
How to setup
1: Create a GlobalAssemblyInfo class.
[assembly: System.Reflection.AssemblyCopyright("Copyright © 2013. All rights reserved.")] [assembly: System.Reflection.AssemblyConfiguration("Release")] [assembly: System.Reflection.AssemblyVersion("1.0.0.2")] [assembly: System.Reflection.AssemblyFileVersion("1.0.0.2")] [assembly: System.Reflection.AssemblyInformationalVersion("1.0.0.2")] internal sealed partial class ThisAssembly { internal const string AssemblyCopyright = "Copyright © 2013. All rights reserved."; internal const string AssemblyConfiguration = "Release"; internal const string AssemblyVersion = "1.0.0.2"; internal const string AssemblyFileVersion = "1.0.0.2"; internal const string AssemblyInformationalVersion = "1.0.0.2"; private ThisAssembly() { } }
2: Remove all the duplicate information in each AssemblyInfo class in each project. This is what it looks like after.
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("ClassLibrary1")] [assembly: AssemblyDescription("a class description")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("231d3658-25f4-425a-b9c4-610f93d10e3e")]
3. Add the existing GlobalAssemblyInfo class as a linked class to each project.
Once you build your solution, all assemblies are built using the version defined in the GlobalAssemblyInfo class.
Now it is easy to set this version in a release build using msbuild. For example the NuGet MSBuildCommunityTasks provides a complete working example for this.
Links:
https://www.nuget.org/packages/MSBuildTasks
http://stackoverflow.com/questions/62353/what-are-the-best-practices-for-using-assembly-attributes
Really enjoyed reading your article, the information you delivered in this post was damn good. Keep sharing your post with efficient news.
https://espirittech.com/dot-net-application-development-company/