Issues with Office 2007 PIA redist and ComponentCheck.exe

A number of people (see this and this for starters) have reported weird behaviour with ComponentCheck.exe which is used as the prerequisite checker for the VSTO Office 2007 PIA redistributable package that was added in Visual Studio 2008 SP1.

For those of you unfamiliar with how the setup.exe is created when an add-in is published, it may come as a surprise to learn that ComponentCheck.exe ends up being embedded directly into setup.exe. When setup.exe is run on the target machine, ComponentCheck.exe is unpacked to a temporary directory and run from there.

If you're running into unexpected behaviour (e.g. the PIA installer running when you believe it shouldn't or, conversely, the PIA installer not running at all when you believe it should), you might want to try testing ComponentCheck.exe by copying it from the %ProgramFiles%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\Office2007PIARedist directory on your Visual Studio 2008 SP1 dev box to an arbitrary location on a test machine and running it from a batch file as follows:

 
@echo off
ComponentCheck.exe
echo %ERRORLEVEL%

This just serves to run the program and echo its output/return value to the console. This script should echo 1 if the PIAs are already installed or 0 otherwise. The PIAInstallAction property is set to this return value and used to block or enable installation of the PIAs respectively (see the <BypassIf Property="PIAInstallAction" Compare="ValueNotEqualTo" Value="0" /> element in product.xml). You might want to consider trying this a machine with Office 2007 PIAs installed and another machine without the Office 2007 PIAs installed.

If you're seeing genuine issues with this component after running this short test, please don't hesitate to let us know.