The best way for me was to do the work in my 32-bit C# wrapper. As the code in my question indicates, Burn doesn't appear to offer any built-in package with VSTO support -- instead I'm just reading the registry manually and basing my logic on that. Burn does offer pre-built packages for .NET 4.0 and .NET 4.5, but I didn't see an easy way to support Fail Early with these.
My C# 2.0 wrapper now includes the following logic:
private static bool NeedsMorePermissionToInstallPrerequisites(out string error)
{
error = string.Empty;
// Is user an admin? If so, we're OK
if (PrivilegeTester.CanBeAdmin())
{
return false;
}
// Is .NET already installed?
bool isDotNetInstalled;
string dotNetVersion;
if (Is64BitOperatingSystem())
{
isDotNetInstalled = PrereqSoftwareChecker.IsDotNet45Installed();
dotNetVersion = "Microsoft .NET 4.5";
}
else
{
isDotNetInstalled = PrereqSoftwareChecker.IsDotNet40Installed();
dotNetVersion = "Microsoft .NET 4.0";
}
// Is VTSO already installed?
bool isVtsoInstalled = PrereqSoftwareChecker.IsVstoRuntimeInstalled();
if (isVtsoInstalled && isDotNetInstalled)
{
return false;
}
// If we got this far, there's trouble. Build the error.
[...]
Here the CanBeAdmin() functionality is based on Calling IPrincipal.IsInRole on Windows 7, and the IsVstoRuntimeInstalled() looks at the exact same set of registry keys that I use in my VSTORuntimeTest, etc. logic in my original question. The .NET checks also look at the registry, using keys that are well documented in MSDN. For example:
internal static bool IsDotNet40Installed()
{
try
{
Version dotnet4Version = new Version(GetHKLMValue("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4.0\\Client", "Version").ToString());
return dotnet4Version >= new Version("4.0.0.0");
}
catch
{
return false;
}
}
private static object GetHKLMValue(string key, string valueName)
{
return Registry.GetValue("HKEY_LOCAL_MACHINE\\" + key, valueName, null);
}
It would be nice if Burn could handle something like this better, but it might be complicated, since simply providing a Fail Early .NET package and a separate Fail Early VSTO package would not be enough to build a full list of packages that would need to be installed independently by an administrator.
Using C# and .NET 2.0 in bootstrapper-wrapper code is obviously a risk here, but I'm guessing that there aren't too many old XP boxes out in the wild that have Office and don't have at least .NET 2.0.