HOW TO: Detect if the Visual C++ 2010 redistributable package is installed with WiX

As noted by Aaron Stebner, there is now a registry key you can search for to detect if the Visual C++ 2010 redistributable package is installed a machine, when installing your application.

There are 3 different (but very similar) registry keys for each of the 3 platform packages. Each key has a DWORD value called “Installed” with a value of 1.

  • HKLM\SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x86
  • HKLM\SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x64
  • HKLM\SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\ia64

Here’s an example of using this in WiX, detecting the presence of the x86 version of the redistributable:

<?xml version="1.0" encoding="utf-8"?>
    <Include>
        <!-- Visual C++ 2010 x86 -->
        <Property Id="HASVCPP2010">
        <RegistrySearch Id="HasVCPP2010Search" Root="HKLM" Key="SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x86" Name="Installed" Type="raw" />
    </Property>   
    <Condition Message="This application requires Microsoft Visual C++ 2010 Redistributable Package (x86).">Installed OR (HASVCPP2010)</Condition>
</Include>

When someone runs your installer and they don’t have this package installed, they will get something like this message box when the installer initializes:

image

It’s a good idea to have a setup bootstrapper that automatically installs this package if it’s missing, but this WiX snippet is a good safe-guard for if someone directly runs your MSI.

Reference: http://blogs.msdn.com/b/astebner/archive/2010/05/05/10008146.aspx

HOW TO: Debug a Windows Installer custom action

Prerequisites:

  • Determine the name of the custom action you want to debug
  • Ensure you have the source code and debug symbols for your custom action

Steps

  1. Set the MsiBreak environment variable (user or system) to the name of the custom action. For example:

    Setx MsiBreak MyCustomActionName

  2. Run your installer
  3. At the point where your custom action is about to run, you should get this message box prompt:

  4. Now you can use Visual Studio or another debugger such as WinDBG to attach to the specified process.
  5. Click OK on the message box
  6. This should break into your debugger. This is a good time to set your breakpoints in your custom action code.
  7. When ready, run/continue the debug session.
  8. Your custom action should run and your breakpoint(s) will be hit.

References:

Debugging Custom Actions @ msdn.microsoft.com