【发布时间】:2015-04-27 12:00:38
【问题描述】:
我有一个 C# 应用程序,我想设置我的应用程序的版本
Assembly.GetExecutingAssembly().GetName().Version,但我的问题是
我如何编辑它的值以及版本值写入的文件在哪里?
【问题讨论】:
标签: c# version .net-assembly
我有一个 C# 应用程序,我想设置我的应用程序的版本
Assembly.GetExecutingAssembly().GetName().Version,但我的问题是
我如何编辑它的值以及版本值写入的文件在哪里?
【问题讨论】:
标签: c# version .net-assembly
它在您的 Properties 文件夹下的 AssemblyInfo.cs 文件中:
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("ConsoleTests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ConsoleTests")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[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("e2e2a417-bd3d-414d-97f9-91196ce1c63a")]
// 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")]
最后两行标识文件版本和程序集版本,这些是您编辑以更改版本的内容。根据您使用的 IDE,该文件可能看起来与上面相同,也可能不同,但您要查找的是 AssemblyVersion 和 AssemblyFileVersion 程序集属性。
【讨论】:
如果您使用的是 Visual Studio,您还可以通过右键单击项目,选择“属性”、“应用程序”选项卡,然后单击“程序集信息”选项卡来更改版本。然后您将看到类似于以下对话框的内容,您可以在其中编辑程序集和文件版本:
【讨论】: