24

I am using Microsoft Visual C# 2010 Express. I have to change the version of my exe file. Please tell me how to do it, either by my C# code, or by batch file.

4

3 回答 3

34

Somewhere in your code (favorably in AssemblyInfo.cs in the Properties folder of your project), put this:

[assembly: AssemblyVersion("1.0.0.0")]

Also possible is the file version attribute:

[assembly: AssemblyFileVersion("1.0.0.0")]

Make sure that you only have one instance of AssemblyVersion and/or AssemblyFileVersion attributes in a single assembly - everything else won't compile.

于 2013-07-09T13:16:27.427 回答
16

You can change the Exe Version through an Assembly file. There are 2 options:

1st option is is to edit the assembly file:

 [assembly: AssemblyTitle("TApplciation Name")]
    [assembly: AssemblyDescription("")]
    [assembly: AssemblyConfiguration("")]
    [assembly: AssemblyCompany("")]
    [assembly: AssemblyProduct("")]
    [assembly: AssemblyCopyright("Copyright ©  2015")]
    [assembly: AssemblyTrademark("")]
    [assembly: AssemblyCulture("")]
    [assembly: AssemblyVersion("5.8.3")]
    [assembly: AssemblyFileVersion("5.8.3")]

2nd option is through project Property. Go To Project Property and click on the button which is circled: enter image description here

Change Application Details

于 2015-09-25T12:13:57.113 回答
0

Just in case someone who stumbled here is trying to change the version of an external exe file (the question title is worded ambiguously), there is a .NET library called Ressy. It helps deal with native resources stored in PE files and edit them. File and product versions are stored in one of such resources, for which Ressy provides first-class support too.

Example: change file and product version of another .exe or .dll file:

using Ressy;
using Ressy.HighLevel.Versions;

var portableExecutable = new PortableExecutable("program.exe");

portableExecutable.SetVersionInfo(v => v
    .SetFileVersion(new Version(1, 2, 3, 4))
    .SetProductVersion(new Version(5, 6, 7, 8))
);
于 2021-12-01T15:34:05.337 回答