[英]Custom File Version/ Product Version of exe by building an application
As the title suggests I need to assign an application a custom file and/or product version by building a project from Visual Studio. 如标题所示,我需要通过从Visual Studio构建项目来为应用程序分配自定义文件和/或产品版本。
I know you can assign a build number from an application publish but I am not publishing these applications, I am simply building "release" files. 我知道您可以从发布的应用程序中分配内部版本号,但是我不是在发布这些应用程序,而是在构建“发布”文件。
Is there a way within Visual Studio to specify these file versions before I build the application? 在构建应用程序之前,Visual Studio中是否可以指定这些文件版本?
Thanks in advance! 提前致谢!
Is there a way within Visual Studio to specify these file versions before I build the application? 在构建应用程序之前,Visual Studio中是否可以指定这些文件版本?
Yes, you can specify File/Product version by AssemblyInfo.cs
before you build the application. 是的,您可以在构建应用程序之前通过AssemblyInfo.cs
指定文件/产品版本。
First , the File version looks for the attribute AssemblyFileVersion
in the AssemblyInfo.cs
file. 首先 ,文件版本在AssemblyInfo.cs
文件中查找属性AssemblyFileVersion
。 So you can specify the File version by setting the value AssemblyFileVersion
. 因此,您可以通过设置值AssemblyFileVersion
来指定文件版本。 I change the AssemblyFileVersion
value from 1.0.0.0
to 2.0.0.0
: 我将AssemblyFileVersion
值从1.0.0.0
更改为2.0.0.0
:
[assembly: AssemblyFileVersion("2.0.0.0")]
Second , ProductVersion first looks to see if the assembly containing the main executable has the AssemblyInformationalVersion
attribute on it. 其次 ,ProductVersion首先查看包含主要可执行文件的程序集是否具有AssemblyInformationalVersion
属性。 If this attribute exists, it is used for Product Version. 如果存在此属性,则将其用于产品版本。 If this attribute does not exist, both properties use the AssemblyFileVersion
instead. 如果此属性不存在,则两个属性都改用AssemblyFileVersion
。
So, in your project, open the AssemblyInfo.cs file. 因此,在您的项目中,打开AssemblyInfo.cs文件。 In this file, I added a line like this: 在此文件中,我添加了这样的一行:
[assembly: AssemblyInformationalVersion("4.0.0.0")]
Then after build is complete. 然后在构建完成之后。 The file version is 2.0.0.0
and the product version is 4.0.0.0
. 文件版本为2.0.0.0
,产品版本为4.0.0.0
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.