@joebigelow / wix / commits / 5fc93f93

Cleanup should always be attempted, and add some logging for it.

Continuation of #6297

Sean Hall committed Feb 6, 2021 at 17:09 UTC 5fc93f9399795156b4a1fbde5f410ca01d94d609
4 files changed +47 -13
src/engine/core.cpp
+15 -8
@@ -1061,7 +1061,7 @@ LExit:
1061 return hr;
1062 }
1063
1064 -extern "C" HRESULT CoreCleanup(
1064 +extern "C" void CoreCleanup(
1065 __in BURN_ENGINE_STATE* pEngineState
1066 )
1067 {
@@ -1069,6 +1069,14 @@ extern "C" HRESULT CoreCleanup(
1069 LONGLONG llValue = 0;
1070 BOOL fNeedsElevation = pEngineState->registration.fPerMachine && INVALID_HANDLE_VALUE == pEngineState->companionConnection.hPipe;
1071
1072 + LogId(REPORT_STANDARD, MSG_CLEANUP_BEGIN);
1073 +
1074 + if (pEngineState->fApplied && BOOTSTRAPPER_ACTION_LAYOUT < pEngineState->plan.action && BOOTSTRAPPER_ACTION_UPDATE_REPLACE > pEngineState->plan.action)
1075 + {
1076 + LogId(REPORT_STANDARD, MSG_CLEANUP_SKIPPED_APPLY);
1077 + ExitFunction();
1078 + }
1079 +
1080 if (fNeedsElevation)
1081 {
1082 hr = VariableGetNumeric(&pEngineState->variables, BURN_BUNDLE_ELEVATED, &llValue);
@@ -1078,12 +1086,11 @@ extern "C" HRESULT CoreCleanup(
1086 {
1087 fNeedsElevation = FALSE;
1088 }
1081 - }
1082 -
1083 - if (pEngineState->fApplied && BOOTSTRAPPER_ACTION_LAYOUT < pEngineState->plan.action && BOOTSTRAPPER_ACTION_UPDATE_REPLACE > pEngineState->plan.action ||
1084 - fNeedsElevation)
1085 - {
1086 - ExitFunction();
1089 + else
1090 + {
1091 + LogId(REPORT_STANDARD, MSG_CLEANUP_SKIPPED_ELEVATION_REQUIRED);
1092 + ExitFunction();
1093 + }
1094 }
1095
1096 if (!pEngineState->fDetected)
@@ -1104,7 +1111,7 @@ extern "C" HRESULT CoreCleanup(
1111 ExitOnFailure(hr, "Apply during cleanup failed");
1112
1113 LExit:
1107 - return hr;
1114 + LogId(REPORT_STANDARD, MSG_CLEANUP_COMPLETE, hr);
1115 }
1116
1117 // internal helper functions
src/engine/core.h
+1 -1
@@ -204,7 +204,7 @@ HRESULT CoreAppendFileHandleSelfToCommandLine(
204 __deref_inout_z LPWSTR* psczCommandLine,
205 __deref_inout_z_opt LPWSTR* psczObfuscatedCommandLine
206 );
207 -HRESULT CoreCleanup(
207 +void CoreCleanup(
208 __in BURN_ENGINE_STATE* pEngineState
209 );
210
src/engine/engine.cpp
+2 -3
@@ -592,13 +592,12 @@ static HRESULT RunNormal(
592 ExitOnFailure(hr, "Failed while running ");
593 } while (fReloadApp);
594
595 +LExit:
596 if (!fSkipCleanup)
597 {
597 - hr = CoreCleanup(pEngineState);
598 - ExitOnFailure(hr, "Failed to cleanup before shutting down");
598 + CoreCleanup(pEngineState);
599 }
600
601 -LExit:
601 BurnExtensionUnload(&pEngineState->extensions);
602
603 // If the message window is still around, close it.
src/engine/engine.mc
+29 -1
@@ -967,7 +967,35 @@ MessageId=501
967 Severity=Warning
968 SymbolicName=MSG_STATE_NOT_SAVED
969 Language=English
970 -The state file could not be saved. Continuing...
970 +The state file could not be saved, error: %1!ls!. Continuing...
971 +.
972 +
973 +MessageId=502
974 +Severity=Success
975 +SymbolicName=MSG_CLEANUP_BEGIN
976 +Language=English
977 +Cleanup begin.
978 +.
979 +
980 +MessageId=503
981 +Severity=Success
982 +SymbolicName=MSG_CLEANUP_SKIPPED_APPLY
983 +Language=English
984 +Cleanup not required due to running Apply.
985 +.
986 +
987 +MessageId=504
988 +Severity=Success
989 +SymbolicName=MSG_CLEANUP_SKIPPED_ELEVATION_REQUIRED
990 +Language=English
991 +Cleanup check skipped since this per-machine bundle would require elevation.
992 +.
993 +
994 +MessageId=599
995 +Severity=Success
996 +SymbolicName=MSG_CLEANUP_COMPLETE
997 +Language=English
998 +Cleanup complete, result: 0x%1!x!
999 .
1000
1001 MessageId=600