C#:如何设置程序集的版本号

时间:2010-10-20 07:28:04

标签: c# versioning

我使用VS2005在C#中编写了一个DLL。

目前,DLL显示的版本号为1.0.0.0。

如何将此版本号设置为不同的版本?

5 个答案:

答案 0 :(得分:18)

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

[assembly: AssemblyVersion("1.0.0.0")]

答案 1 :(得分:8)

右键单击该项目,然后单击属性。 将出现属性窗口。单击“应用程序”选项卡。 它将显示项目的应用信息。将有一个名为Assembly Information的按钮。单击按钮,它将显示包含项目的程序集信息的表单。您可以指定程序集版本(包含四个文本框,即主要版本,次要版本,内部版本号,修订版)。它会将程序集详细信息存储在相应项目的AssemblyInfo.cs中。

答案 2 :(得分:5)

您可以直接使用AssemblyFileVersionAttribute指定文件版本...

  

指示编译器使用特定的   Win32文件的版本号   版本资源。

...或者您可以完全删除此属性,这意味着文件版本默认为程序集版本。这可能是一种很好的做法,因为文件版本与程序集版本不同会导致混淆。

  

如果AssemblyFileVersionAttribute是   没提供,   AssemblyVersionAttribute用于   Win32文件版本   显示在的版本选项卡上   Windows文件属性对话框。

您可以使用AssemblyVersionAttribute设置装配版本。

程序集属性通常应用于AssemblyInfo.cs文件中,如其他答案中所述。

答案 3 :(得分:4)

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

答案 4 :(得分:4)

您可以在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")]

请注意,程序集版本与程序集文件版本不同。从您的简短描述中,听起来更像是在寻找后者 - AssemblyFileVersion