简体   繁体   English

通过构建应用程序的exe的自定义文件版本/产品版本

[英]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.

相关问题 使文件版本反映产品内部版本号和特定 dll/exe 版本的方法是什么? - What is the way to make file version reflect both product build number and version of the specific dll/exe? 使用不同版本的 Visual Studio 构建 C++ 代码会产生不同的 .exe 文件大小? - Building C++ code with different version of Visual Studio produces different file size of .exe? C#应用程序的构建发行版 - Building Release Version of a C# application exe版本中不提供用户手册文本文件 - User manual text file not available in the exe version 在MSBuild中获取本机exe的文件版本 - Getting the file version of a native exe in MSBuild 在 C# 中将产品版本和文件版本设置为不同的数字 - Set Product Version and File Version to different numbers in C# 在C#Visual Studio桌面应用程序的exe文件名中包含版本号 - Include version number in exe file name in C# Visual Studio desktop application 在 Visual Studio 中构建 C# 应用程序时,如何在可执行文件名中嵌入版本信息? - How to embed the version information in the executable file name when building C# application in Visual Studio? 更改.exe文件版本(来自C ++项目) - Change .exe file version (from C++ project) C#应用程序在已部署(.exe)版本中因缓冲区溢出而崩溃,但在Visual Studio中却没有 - C# Application crashes with Buffer Overrun in deployed (.exe) version, but not in Visual Studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM