简体   繁体   中英

C#: how to set version number of assembly

I have written a DLL in C# using VS2005.

Currently the DLL is showing a version number of 1.0.0.0.

How do I set this version number to something different?

在 AssemblyInfo.cs 文件中查找以下行,并将其设置为您想要的任何版本号:

[assembly: AssemblyVersion("1.0.0.0")]

You can either specify the file version using the AssemblyFileVersionAttribute directly...

Instructs a compiler to use a specific version number for the Win32 file version resource.

...or you can remove this attribute entirely which will mean that the file version defaults to the assembly version. This is probably good practice as having a file version that is different to the assembly version will cause confusion.

If the AssemblyFileVersionAttribute is not supplied, the AssemblyVersionAttribute is used for the Win32 file version that is displayed on the Version tab of the Windows file properties dialog.

You can set the assembly version using the AssemblyVersionAttribute .

Assembly attributes are usually applied in the AssemblyInfo.cs file as stated in the other answers.

Right click the project and click properties. The properties window will appear. In that click Application tab. It will show application information of the project. There will be a button named Assembly Information. click the button, it will show you a form containing assembly information of the project. You can specify the assembly version (contains four text boxes, ie, Major Version, Minor Version, Build Number, Revision). It will store the assembly details in AssemblyInfo.cs of the corresponding project.

You can set the version number in AssemblyInfo.cs .

// 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 
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Note that the assembly version is not the same as the assembly file version. From your brief description it sounds more like you are looking for the latter - AssemblyFileVersion .

Alter this line in AssemblyInfo.cs:

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
[assembly: AssemblyVersion("1.9.10292.8")]

If you need to change it on visual studio open your solution file then right click and select properties then select Application on that select assembly information than change version on assembly. enter image description here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM