33 lines
2.1 KiB
C#
33 lines
2.1 KiB
C#
using System;
|
|
using System.IO;
|
|
|
|
// Pure bootstrapper contract, shared with the upgrade regression. The complete
|
|
// desktop application must be installed locally, never advertised on demand.
|
|
public static class CompanionUpgradePolicy
|
|
{
|
|
public static void EnsureLocalFeature(Func<int> query, Func<uint> installLocal, Action<string> log)
|
|
{
|
|
int state = query(); log("Complete feature before local configuration=" + state);
|
|
if (state == 3) return;
|
|
if (state != 1 && state != 2 && state != 4) throw new InvalidDataException("Unexpected Complete feature state " + state + ". No local configuration was attempted.");
|
|
// REINSTALL repairs the existing state, including Advertised. It does not
|
|
// promote that state to Local, even with ADDLOCAL in the recache request.
|
|
uint result = installLocal(); log("Explicit ConfigureFeature(Local) result=" + result);
|
|
if (result != 0 && result != 3010) throw new InvalidOperationException("Installing Complete locally failed with Windows Installer code " + result + ". Retain the local-feature log.");
|
|
state = query(); log("Complete feature after local configuration=" + state);
|
|
if (state != 3) throw new InvalidDataException("Complete feature remained " + state + " after local configuration; required Local=3. Installation is not accepted.");
|
|
}
|
|
public static string InstallProperties(bool alreadyRegistered)
|
|
{
|
|
string properties = "ALLUSERS=\"\" MSIINSTALLPERUSER=1 REBOOT=ReallySuppress ADDLOCAL=Complete REINSTALLMODE=vamus";
|
|
return alreadyRegistered ? properties + " REINSTALL=ALL" : properties;
|
|
}
|
|
public static void VerifyVersions(string expected, string wordVersion, string agentVersion)
|
|
{
|
|
if (wordVersion != expected || agentVersion != expected)
|
|
throw new InvalidDataException("Installed component version mismatch. Expected " + expected +
|
|
"; Word add-in detected " + (wordVersion ?? "missing") +
|
|
"; tray executable detected " + (agentVersion ?? "missing") + ". Retain the setup log; no trust or Office repair was attempted.");
|
|
}
|
|
}
|