7

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

Kate Orlova
  • 3,225
  • 5
  • 11
  • 35
SLEO
  • 73
  • 1
  • 2
  • 6
  • 3
    You could create one `SharedAssemblyInfo.cs` file and link it in every project, that way changing it in one place changes it in all of them. – Ron Beyer Nov 18 '15 at 14:39
  • where are you finding the information posted in the first screenshot? I'm not familiar with where to view that information – Kritner Nov 18 '15 at 14:40
  • @Kritner If you expand (not double click) the properties folder, there is a file called "AssemblyInfo.cs" that contains that information. The other screen shot is when you right click on the DLL and select "Properties>Details". – Ron Beyer Nov 18 '15 at 14:43
  • @RonBeyer I'm familiar with assemblyinfo (the second screenshot) I'm just not sure where the first screenshot is being viewed from. – Kritner Nov 18 '15 at 14:44
  • Its part of the standard windows file properties dialog, apart from Visual Studio. – Ron Beyer Nov 18 '15 at 15:19
  • 1- Ron : i did that and i make only one master assemblyinfo and rebuild the solution and it is only update the exe version , what i want is also to update the dll file – SLEO Nov 18 '15 at 17:58
  • 2- kritner : the first screen is in:: right click -------> properties ---> details – SLEO Nov 18 '15 at 18:01
  • 3- RonBeyer:: the first screen is in:: right click on dll file -------> properties ---> details – SLEO Nov 18 '15 at 18:02
  • If your dll code is not modifed, it wont build, thus no version change. however if your dll is also build again at the same time with exe code, then most probably forget to set the version number to 1.0.* – AaA Mar 12 '18 at 01:34
  • For my case, I gave up on visual studio version increment. I wrote a small console app which I run before build and it modifies `AssemblyInfo.cs` file in all my projects and increments the version and because a file is modified, all outputs including dlls get built again with my desired version number – AaA Mar 12 '18 at 01:36
  • This question has a complete solution and discussion. https://stackoverflow.com/q/759644/365188 – Ozair Kafray Aug 19 '20 at 15:19

4 Answers4

4

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

Vishnu Babu
  • 1,183
  • 1
  • 13
  • 37
3

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.

Rickchip
  • 371
  • 1
  • 4
  • 12
  • Could you please summarize the most relevant parts of the article here in case the link changes? – ForeverZer0 Jul 12 '18 at 23:04
  • 1
    @ForeverZer0 Updated. Let me know if this level of detail is sufficient. I'm trying to summarize without rewriting the article linked. – Rickchip Jul 12 '18 at 23:55
1

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.
Kritner
  • 13,557
  • 10
  • 46
  • 72
  • it will and i did that but the problem is only the exe file get updated after build , what i want is also the dll file to be change as exe changed – SLEO Nov 18 '15 at 17:51
  • any `DLL`s that get built with your `EXE` are separate assemblies with their own AssemblyInfo classes. Are you sure you would you want all dependent `DLL`s to have the same version number? What happens when those `DLL`s are used for separate `EXE`s with their own version number? The version applies to the assembly, not the application (generally speaking) – Kritner Nov 18 '15 at 18:02
  • i need it because i want to generate a release with specific version of application for all files (dll and exe ), and my boss ask me to do it – SLEO Nov 18 '15 at 18:08
0

It's a simple solution that works for asp.net applications.

Go to project properties => Application (tab) (see below image for reference)


Click on Assembly Information and there you will find Assembly Version and File Version.

enter image description here

A H
  • 85
  • 7