C#: how to set version number of assembly

非 Y 不嫁゛ 提交于 2019-12-30 16:23:26

问题


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?


回答1:


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.




回答2:


look in the AssemblyInfo.cs file for the following line, and set it to whatever version number you want:

[assembly: AssemblyVersion("1.0.0.0")]



回答3:


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, i.e., Major Version, Minor Version, Build Number, Revision). It will store the assembly details in AssemblyInfo.cs of the corresponding project.




回答4:


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")]



回答5:


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.



来源:https://stackoverflow.com/questions/3975601/c-how-to-set-version-number-of-assembly

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!