Introduction
Changing the assembly version and assembly file version in AssemblyInfo.cs.
Guidelines to be followed
- Step 1: List out common parameters and dynamically changing one from AssemblyInfo.cs which is present under properties.
- Step 2: Copy AssemblyInfo.cs and put it in root directory of Solution Explorer and rename it to SolutionInfo.cs.
- Step 3: Put the Constant Parameters in SolutionInfo.cs and remove the remaining parameters.
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security.Permissions;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WindowsFormsCheckVersion")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyFileVersion("1.0.*")]
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("WindowsFormsCheckVersion")]
[assembly: AssemblyDescription("")]
[assembly: Guid("e2ff28a6-9772-4681-9778-d8e4bed68ce0")]
Step 4: Remove the parameters that are mentioned in SolutionInfo.cs.
Step 5: Create a new folder under Solution Explorer, name it to SolutionItem, and add the SolutionInfo.cs file to this folder.
Step 6: Now Right click on Project > Add >Existing Item >select the solutionInfo.cs file, and choose Add Link File.
(This has to be done to all projects where ever you need to change version Number)We need to keep it in mind that we should remove the parameters that are placed in SolutionInfo.cs.
If you want to check that version has been changed at all places we can check it with DLL or we can get it through application code also.
Assembly executingAssembly;
AssemblyName executingAssemblyName;
Version executingAssemblyVersion;
executingAssembly = Assembly.GetEntryAssembly();
executingAssemblyName = executingAssembly.GetName();
executingAssemblyVersion = executingAssemblyName.Version;
string assemblyVersion = executingAssemblyVersion.ToString(4);
MessageBox.Show(assemblyVersion);
string path;
path = System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
MessageBox.Show(path);
Point to remember
Make sure that parameters that are placed under solutionInfo.cs should be removed in all AssemblyInfo.cs.