How to change the version of all files in Visual Studio

22,038

Solution 1

Assembly information can be changed by editing Assemblyinfo.cs file that can be seen under properties of your project in solution explorer, Here you can change the version of the assembly

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("My App Title")]
[assembly: AssemblyDescription("App Description")]
[assembly: AssemblyCompany("My Company Name")]
[assembly: AssemblyProduct("ConsoleApp")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("My Company Trademark")]
[assembly: AssemblyCulture("")]

// 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("513436d3-aa2f-407b-83d2-9268300cc373")]

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Build and Revision Numbers 

//*******Assembly Version can be changed here*********
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

OR

  • Go to Solution Explorer
  • Right Click on your project
  • select properties
  • In the window that appears click Assembly Information
  • In the pop-up box you can edit assembly related details
  • Click 'ok' and your AssemblyInfo.cs file can be seen updated automatically

    pop-up box where you can edit assembly related details

Solution 2

I know this is an older question but here's a great article on managing versions in a solution with multiple assemblies.

https://jonthysell.com/2017/01/10/automatically-generating-version-numbers-in-visual-studio/

It shows three options for managing versioning in an AssemblyInfo.cs file.

  1. Using the built in wildcard operators to automatically generate the Build and Release numbers, which still requires manually updating the Major and Minor versions.
  2. Using a 3rd party Visual Studio extension.
  3. Using a template file (*.tt) which is shared between all projects in the solution to customize how the numbers are generated based on whether it's a Preview or Production release.

I found option 3 most useful for my application and easiest to maintain since you have a single file shared between all assemblies and can customize the numbers easily to match your particular situation.

Solution 3

As the comments in the AssemblyInfo.cs point out, if you were to change:

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Revision and Build Numbers 
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

to:

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Revision and Build Numbers 
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]

The assembly will get a new build number/revision after each build.

From MSDN:

You can specify all the values or you can accept the default build number, revision number, or both by using an asterisk (). For example, [assembly:AssemblyVersion("2.3.25.1")] indicates 2 as the major version, 3 as the minor version, 25 as the build number, and 1 as the revision number. A version number such as [assembly:AssemblyVersion("1.2.")] specifies 1 as the major version, 2 as the minor version, and accepts the default build and revision numbers. A version number such as [assembly:AssemblyVersion("1.2.15.*")] specifies 1 as the major version, 2 as the minor version, 15 as the build number, and accepts the default revision number. The default build number increments daily. The default revision number is the number of seconds since midnight local time (without taking into account time zone adjustments for daylight saving time), divided by 2.

Tutorial on shared assembly info:

http://theburningmonk.com/2010/03/net-tips-use-a-shared-assemblyinfo-cs-for-your-solution/

  1. cre­ate a file, say SharedAssemblyInfo.cs, at the solution’s root direc­tory and put all the common settings there.
  2. right-click on your project and Add an Existing Item…, browse to the SharedAssemblyInfo.cs, and make sure you choose to Add As Link.
Share:
22,038
Admin
Author by

Admin

Updated on August 07, 2020

Comments

  • Admin
    Admin over 3 years

    I have a solution in Visual Studio which has many projects and DLL files, how to change the version of all files in solution (dll and exe files) before build or after?

    [Solutions infos

    [AssemblyInfo