How to get MSI product version Programatically in C #

Is there an MSI version of the app available?

I tried Assembly.GetExecutingAssembly (). GetName (). Version, but this gives me an assembly version which is different from what I want. I can change this value in the appropriate location, but it would be handy if I could just show the version number from the MSI installer.

Another point is that the MSI version number has 3 parts, each part of which is separated by a '.' Character, like 1.0.3, where because the build number has 4 parts, like 1.0.2.4.

From this I conclude that we must update these values ​​separately and it is impossible to synchronize them.

Do I understand correctly?

+2


a source to share


1 answer


MSI is allowed to have four parts listed for its version, although they will only compare the first three (which can cause confusion when trying a minor update with updates only in the fourth part). This way you can certainly keep your numbers in sync in some kind of build script if your install solution is scriptable.



As for showing the MSI version from your application, you need to know your ProductCode so that you can search for the MSI API version. Alternatively, you can write a registry entry containing the version in a more stable location and read it in your application.

+3


a source







All Articles