C# - Get version of Setup project msi/exe file

513 Views Asked by At

I'm trying to get the version from MSI/exe files.

Pic

enter image description here

I tried both exe and msi file but it returns as null.

var versionInfo = FileVersionInfo.GetVersionInfo(@"path\setup.exe");
            string version = versionInfo.FileVersion; 

I tried write the version in the description field and read it but again, it returns as null.

How can I get this field by code ?

1

There are 1 best solutions below

2
On

In Visual Studio, right click your project and go to Properties. From Properties go to Package->General and scroll down to find "File Version". Here you can set the File Version property of the file when it is compiled.

File Version

The code you provided can now retrieve the version!

Print File Version