I have a wpf project for which the installer is created by wix setup project. the wix setup project is compiled to get the .msi. The .exe is generated from the .msi file using wix bootstrapper project.Now my question is how to get the assembly version [assembly: AssemblyFileVersion("x.x.x.xx")] form wpf .cs file?
-
You're not going to get it out a cs file. Wix knows nothing about the code that compiles into your app. You need to get it off the exe like this. https://stackoverflow.com/questions/626033/how-can-i-set-the-wix-installer-version-to-the-current-build-version – Andy Mar 06 '20 at 15:25
-
It's not working in Bundle.wxs. – Debabrata Mar 07 '20 at 03:16
1 Answers
Andy is right, you will not be able to pull the version number from a .cs file as WiX does not compile or know anything to do with the C# code.
What you want to do is version your main executable file (presumably the .csproj application) using the assembly version properties. (These can be found in the project properties)
1) In the Product.wxs add said main executable as a file in the installer.
<Component Id='MainExecutable' Guid='*'>
<File Id='MainExe' Name='MainExe.exe' Source='Path-to-exe' KeyPath='yes' />
</Component>
2) Bind the version of the .msi to this main executable. This is done in the Version attribute of the Product element.
<Product Id="*" Name="My Product Name" Language="1033" Version="!(bind.FileVersion.MainExe)" Manufacturer="Debabrata" UpgradeCode="PUT-GUID-HERE">
Not that the value after the FileVersion is the ID of your file. This is important.
Now to use this version number in the bootstrapper project - the process is very similar.
1) Add the MSI to the bootstrapper.
<MsiPackage SourceFile="Path-to-msi" Id="MyMSI">
2) In the Version attribute of the Bundle element the binding should be.
<Bundle Name="My Bundle" Version="!(bind.packageVersion.MyMSI)">
Again, note how the ID matches.
Hope this helps!

- 1,724
- 2
- 14
- 27
-
Thanks Ryan. Looks good. Help me to bind dynamically project version with .exe name. Like ProductName_V_1_0_0_1.exe – Debabrata Mar 10 '20 at 11:58
-
Is that the format you want the bootstrap title to be? The MSI or both? – Ryan Thomas Mar 10 '20 at 12:29
-
@RyanThomas, I had a similar query - where I want to display the product version according to a particular format in the ARP. Something like: Major.Minor.Build "some string" Revision. Example: "3.3.0 Build 144". Any suggestion? – ArNumb Mar 10 '20 at 16:40
-
@ArNumb I'm not sure what you mean by ARP. But you can use !(bind.property.ProductVersion.Major) to get specific parts of the version number inside your product. See WiX documentation here. https://wixtoolset.org/documentation/manual/v3/overview/light.html – Ryan Thomas Mar 11 '20 at 09:03
-
Thanks @RyanThomas. By ARP, I meant Add Remove Program (inside Control Panel). I have already used !(bind.property...) for my bundle. But it seems to only take integer values. I wanted the Control Panel entry for my product to display a string type of value in the Version field. Something like: 3.3.0 xxx 144 (where xxx is some customizable string.) – ArNumb Mar 11 '20 at 12:26
-
@RyanThomas sorry for late reply, I need bootstrapper output .exe file name combination of ProductNameWith version dynamically(version number). – Debabrata Mar 13 '20 at 07:52