Exe不包含Properties / Details中的Version

时间:2015-04-28 15:02:10

标签: c# windows visual-studio

我有一个C#项目,并指定了程序集和文件版本。 但是在Project.exe的属性/详细信息下,字段文件版本为空。我是否必须在项目设置中设置某些内容或者这是正常的行为?

Assembly.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("Application")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Firm")]
[assembly: AssemblyProduct("Application")]
[assembly: AssemblyCopyright("Firm ©  2014")]
[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("long guid")]

// 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: AssemblyFileVersionAttribute("1.0.1")]

2 个答案:

答案 0 :(得分:0)

仔细检查可执行项目的AssemblyInfo.cs文件,确保该文件正确设置了属性[assembly: AssemblyFileVersion("1.0.0.0")](其中1.0.0.0是您想要的版本)。

答案 1 :(得分:0)

所以,我已经通过以下方式解决了我的问题:

  • 我已在Project properties / Application下设置回“Icon and Manifest”并为我的项目指定了单个图标
  • 要在没有Win32资源的情况下将多个图标嵌入到我的exe中,我使用了InsertIcons.exe

所以问题是:如果你为你的图标指定了一个Win32资源,那么输出exe中就不会嵌入任何清单文件。在这种情况下,您可能必须向此资源添加版本资源以包含版本数据。在这种情况下,您必须手动为每个构建定义版本,构建等(我没有找到其他方法来避免此行为)。奇怪的是,即使不添加版本资源,软件本身仍然可以从自己的AssemblyInformation获取数据。

相关问题