Search code examples
visual-studioinstallationwindows-installervisual-studio-setup-proje

MSI Installer: Conditionally include one or another file for 32 or 64-bit systems


I'm using Visual Studio Setup Project to create installer for my application.

One of the files needs to included or excluded depending upon whether the target machine is 32 or 64-bit. The setup project does have a property named TargetPlatform. Can I use it in Condition property of that file to achieve this?

I already went ahead and tried writing the condition: [TARGETPLATFORM] = 'x86'. But it doesn't seem to work.

This is VS2019 Community.


Solution

  • For this you can use the VersionNT64 property to conditionally install files based on the OS bitnesss.

    The installer sets the VersionNT64 property to the version number for the operating system only if the system is running on a 64-bit computer. The property is undefined if the operating system is not 64-bit.

    Check the VersionNT64 property article.