Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/burn/engine/apply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,6 @@ extern "C" HRESULT ApplyUnregister(
IgnoreRollbackError(hrRegistrationRollback, "Dependent registration actions failed");
}

LogId(REPORT_STANDARD, MSG_SESSION_END, pEngineState->registration.sczRegistrationKey, LoggingInstallScopeToString(pEngineState->registration.fPerMachine), LoggingResumeModeToString(resumeMode), LoggingRestartToString(restart), LoggingBoolToString(pEngineState->registration.fDisableResume), LoggingRegistrationTypeToString(defaultRegistrationType), LoggingRegistrationTypeToString(registrationType));

if (BOOTSTRAPPER_ACTION_UNSAFE_UNINSTALL == pEngineState->plan.action)
{
registrationType = BOOTSTRAPPER_REGISTRATION_TYPE_NONE;
Expand All @@ -546,6 +544,8 @@ extern "C" HRESULT ApplyUnregister(
LogId(REPORT_STANDARD, MSG_UNSAFE_SESSION_END);
}

LogId(REPORT_STANDARD, MSG_SESSION_END, pEngineState->registration.sczRegistrationKey, LoggingInstallScopeToString(pEngineState->registration.fPerMachine), LoggingResumeModeToString(resumeMode), LoggingRestartToString(restart), LoggingBoolToString(pEngineState->registration.fDisableResume), LoggingRegistrationTypeToString(defaultRegistrationType), LoggingRegistrationTypeToString(registrationType));

if (pEngineState->registration.fPerMachine)
{
hr = ElevationSessionEnd(pEngineState->companionConnection.hPipe, resumeMode, restart, pEngineState->registration.fDetectedForeignProviderKeyBundleCode, qwEstimatedSize, registrationType);
Expand Down
5 changes: 5 additions & 0 deletions src/burn/engine/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ extern "C" HRESULT CoreQueryRegistration(
SIZE_T cbBuffer = 0;
SIZE_T iBuffer = 0;

// Detect if bundle is already installed.
hr = RegistrationDetectInstalled(&pEngineState->registration, &pEngineState->cache);
ExitOnFailure(hr, "Failed to detect bundle install state.");

// detect resume type
hr = RegistrationDetectResumeType(&pEngineState->registration, &pEngineState->command.resumeType);
ExitOnFailure(hr, "Failed to detect resume type.");
Expand Down Expand Up @@ -2280,6 +2284,7 @@ static HRESULT DetectPackagePayloadsCached(
LExit:
ReleaseStr(sczPayloadCachePath);
ReleaseStr(sczCachePath);

return hr;
}

Expand Down
2 changes: 1 addition & 1 deletion src/burn/engine/engine.mc
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ MessageId=371
Severity=Success
SymbolicName=MSG_SESSION_UPDATE
Language=English
Updating session, registration key: %1!ls!, scope: %2!hs!, resume: %3!hs!, restart initiated: %4!hs!, disable resume: %5!hs!
Updating session, registration key: %1!ls!, scope: %2!hs!, resume: %3!hs!, restart initiated: %4!hs!, disable resume: %5!hs!, registration: %6!hs!
.

MessageId=372
Expand Down
38 changes: 24 additions & 14 deletions src/burn/engine/registration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static HRESULT EnsureRegistrationVariable(
);
static HRESULT UpdateResumeMode(
__in BURN_REGISTRATION* pRegistration,
__in HKEY hkRegistration,
__in_opt HKEY hkRegistration,
__in BURN_RESUME_MODE resumeMode,
__in BOOTSTRAPPER_REGISTRATION_TYPE registrationType,
__in BOOL fRestartInitiated
Expand Down Expand Up @@ -461,13 +461,7 @@ extern "C" HRESULT RegistrationSetDynamicVariables(
)
{
HRESULT hr = S_OK;
LONGLONG llInstalled = 0;

// Detect if bundle is already installed.
hr = RegistrationDetectInstalled(pRegistration);
ExitOnFailure(hr, "Failed to detect bundle install state.");

llInstalled = BOOTSTRAPPER_REGISTRATION_TYPE_FULL == pRegistration->detectedRegistrationType ? 1 : 0;
LONGLONG llInstalled = BOOTSTRAPPER_REGISTRATION_TYPE_FULL == pRegistration->detectedRegistrationType ? 1 : 0;

hr = VariableSetNumeric(pVariables, BURN_BUNDLE_INSTALLED, llInstalled, TRUE);
ExitOnFailure(hr, "Failed to set the bundle installed built-in variable.");
Expand All @@ -483,7 +477,8 @@ extern "C" HRESULT RegistrationSetDynamicVariables(
}

extern "C" HRESULT RegistrationDetectInstalled(
__in BURN_REGISTRATION* pRegistration
__in BURN_REGISTRATION* pRegistration,
__in BURN_CACHE* pCache
)
{
HRESULT hr = S_OK;
Expand All @@ -496,14 +491,28 @@ extern "C" HRESULT RegistrationDetectInstalled(
{
// For PUOM/PMOU bundles, check per-machine then fall back to per-user.
hr = DetectInstalled(pRegistration, HKEY_LOCAL_MACHINE);
if (SUCCEEDED(hr))
{
pRegistration->fPerMachine = TRUE;

if (FAILED(hr))
hr = RegistrationSetPaths(pRegistration, pCache);
ExitOnFailure(hr, "Failed to set registration paths for per-machine configurable scope.");
}
else
{
hr = DetectInstalled(pRegistration, HKEY_CURRENT_USER);

if (SUCCEEDED(hr))
{
pRegistration->fPerMachine = FALSE;

hr = RegistrationSetPaths(pRegistration, pCache);
ExitOnFailure(hr, "Failed to set registration paths for per-user configurable scope.");
}
}
}

//LExit:
LExit:
// Not finding the key or value is okay.
if (E_FILENOTFOUND == hr || E_PATHNOTFOUND == hr)
{
Expand Down Expand Up @@ -1086,6 +1095,8 @@ extern "C" HRESULT RegistrationSetPaths(
hr = PathConcatRelativeToFullyQualifiedBase(sczCacheDirectory, pRegistration->sczExecutableName, &pRegistration->sczCacheExecutablePath);
ExitOnFailure(hr, "Failed to build cached executable path.");

pRegistration->fCached = pRegistration->sczCacheExecutablePath && FileExistsEx(pRegistration->sczCacheExecutablePath, NULL);

// build state file path
hr = StrAllocFormatted(&pRegistration->sczStateFile, L"%ls\\state.rsm", sczCacheDirectory);
ExitOnFailure(hr, "Failed to build state file path.");
Expand Down Expand Up @@ -1242,7 +1253,7 @@ static HRESULT EnsureRegistrationVariable(

static HRESULT UpdateResumeMode(
__in BURN_REGISTRATION* pRegistration,
__in HKEY hkRegistration,
__in_opt HKEY hkRegistration,
__in BURN_RESUME_MODE resumeMode,
__in BOOTSTRAPPER_REGISTRATION_TYPE registrationType,
__in BOOL fRestartInitiated
Expand All @@ -1254,7 +1265,7 @@ static HRESULT UpdateResumeMode(
LPWSTR sczRunOnceCommandLine = NULL;
LPCWSTR sczResumeKey = REGISTRY_RUN_ONCE_KEY;

LogId(REPORT_STANDARD, MSG_SESSION_UPDATE, pRegistration->sczRegistrationKey, LoggingInstallScopeToString(pRegistration->fPerMachine), LoggingResumeModeToString(resumeMode), LoggingBoolToString(fRestartInitiated), LoggingBoolToString(pRegistration->fDisableResume));
LogId(REPORT_STANDARD, MSG_SESSION_UPDATE, pRegistration->sczRegistrationKey, LoggingInstallScopeToString(pRegistration->fPerMachine), LoggingResumeModeToString(resumeMode), LoggingBoolToString(fRestartInitiated), LoggingBoolToString(pRegistration->fDisableResume), LoggingRegistrationTypeToString(registrationType));

// write resume information
if (hkRegistration)
Expand Down Expand Up @@ -1776,7 +1787,6 @@ static HRESULT DetectInstalled(
DWORD dwInstalled = 0;
DWORD dwScope = 0;

pRegistration->fCached = pRegistration->sczCacheExecutablePath && FileExistsEx(pRegistration->sczCacheExecutablePath, NULL);
pRegistration->detectedRegistrationType = BOOTSTRAPPER_REGISTRATION_TYPE_NONE;
pRegistration->detectedScope = BOOTSTRAPPER_SCOPE_DEFAULT;

Expand Down
3 changes: 2 additions & 1 deletion src/burn/engine/registration.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ HRESULT RegistrationSetDynamicVariables(
__in BURN_VARIABLES* pVariables
);
HRESULT RegistrationDetectInstalled(
__in BURN_REGISTRATION* pRegistration
__in BURN_REGISTRATION* pRegistration,
__in BURN_CACHE* pCache
);
HRESULT RegistrationDetectResumeType(
__in BURN_REGISTRATION* pRegistration,
Expand Down
11 changes: 11 additions & 0 deletions src/test/burn/WixToolsetTest.BurnE2E/ConfigurableScopeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@ public void BundleUpgradeIsLockedToFirstBundlesScope()

Assert.True(LogVerifier.MessageInLogFile(log, "Plan begin, 3 packages, action: Install, planned scope: Default"));

log = bundle.Modify();
Assert.True(LogVerifier.MessageInLogFile(log, "TESTBA: OnDetectBegin: Cached=True"));
Assert.False(LogVerifier.MessageInLogFile(log, "Could not load or read state file:"));

log = bundle.Repair();
Assert.False(LogVerifier.MessageInLogFile(log, "Could not load or read state file:"));
Assert.True(LogVerifier.MessageInLogFile(log, "Bundle was already installed with scope: PerUser. Scope cannot change during maintenance."));

var bundleV2 = this.CreateBundleInstaller("AllPuomBundleTestBAv2");
Expand All @@ -132,6 +137,8 @@ public void BundleUpgradeWithSameScopeSucceeds()
Assert.True(LogVerifier.MessageInLogFile(log, "Plan begin, 3 packages, action: Install, planned scope: Default"));

log = bundle.Repair();
Assert.True(LogVerifier.MessageInLogFile(log, "TESTBA: OnDetectBegin: Cached=True"));
Assert.False(LogVerifier.MessageInLogFile(log, "Could not load or read state file:"));
Assert.True(LogVerifier.MessageInLogFile(log, "Bundle was already installed with scope: PerUser. Scope cannot change during maintenance."));

var bundleV2 = this.CreateBundleInstaller("AllPuomBundleTestBAv2");
Expand Down Expand Up @@ -164,6 +171,8 @@ public void PMOU_Bundle_Default_Plan_Installs_PerMachine()
Assert.True(LogVerifier.MessageInLogFile(log, "Planned package: PmouPkg2.msi, state: Absent, default requested: Present, ba requested: Present, execute: Install, rollback: Uninstall, scope: PerMachine,"));

log = bundle.Repair();
Assert.True(LogVerifier.MessageInLogFile(log, "TESTBA: OnDetectBegin: Cached=True"));
Assert.False(LogVerifier.MessageInLogFile(log, "Could not load or read state file:"));
Assert.True(LogVerifier.MessageInLogFile(log, "Bundle was already installed with scope: PerMachine"));
Assert.True(LogVerifier.MessageInLogFile(log, "Detected package: PmouPkg1.msi, state: Present, authored scope: PerMachineOrUser, detected scope: PerMachine,"));
Assert.True(LogVerifier.MessageInLogFile(log, "Detected package: PmouPkg2.msi, state: Present, authored scope: PerMachineOrUser, detected scope: PerMachine,"));
Expand Down Expand Up @@ -508,6 +517,8 @@ public void PM_PU_PMOU_Bundle_Default_Plan_Installs_PerMachine()
Assert.True(LogVerifier.MessageInLogFile(log, "Planned package: PerUserPkg.msi, state: Absent, default requested: Present, ba requested: Present, execute: Install, rollback: Uninstall, scope: PerUser"));

log = bundle.Repair();
Assert.True(LogVerifier.MessageInLogFile(log, "TESTBA: OnDetectBegin: Cached=True"));
Assert.False(LogVerifier.MessageInLogFile(log, "Could not load or read state file:"));
Assert.True(LogVerifier.MessageInLogFile(log, "Detected package: PerMachinePkg.msi, state: Present, authored scope: PerMachine, detected scope: PerMachine,"));
Assert.True(LogVerifier.MessageInLogFile(log, "Detected package: PmouPkg1.msi, state: Present, authored scope: PerMachineOrUser, detected scope: PerMachine,"));
Assert.True(LogVerifier.MessageInLogFile(log, "Detected package: PmouPkg2.msi, state: Present, authored scope: PerMachineOrUser, detected scope: PerMachine,"));
Expand Down