aboutsummaryrefslogtreecommitdiff
path: root/src/burn/engine/msiengine.cpp
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-12-07 17:34:09 -0600
committerSean Hall <r.sean.hall@gmail.com>2021-12-08 17:14:11 -0600
commit19d85eed389fbd964f64c2fbb85e40ec20439d26 (patch)
tree29adf2c191ea8a50153238ee457ff34f0d73d059 /src/burn/engine/msiengine.cpp
parent5c7b1a8fa2b02ddd758c0c267f59b7e77b527f62 (diff)
downloadwix-19d85eed389fbd964f64c2fbb85e40ec20439d26.tar.gz
wix-19d85eed389fbd964f64c2fbb85e40ec20439d26.tar.bz2
wix-19d85eed389fbd964f64c2fbb85e40ec20439d26.zip
Add ability to customize file versioning rules for MsiPackage and MspPackage.
Fixes #5911
Diffstat (limited to 'src/burn/engine/msiengine.cpp')
-rw-r--r--src/burn/engine/msiengine.cpp140
1 files changed, 93 insertions, 47 deletions
diff --git a/src/burn/engine/msiengine.cpp b/src/burn/engine/msiengine.cpp
index c80fd79f..509fbb7a 100644
--- a/src/burn/engine/msiengine.cpp
+++ b/src/burn/engine/msiengine.cpp
@@ -958,8 +958,8 @@ extern "C" HRESULT MsiEnginePlanAddPackage(
958 pAction->msiPackage.rgFeatures = rgRollbackFeatureActions; 958 pAction->msiPackage.rgFeatures = rgRollbackFeatureActions;
959 rgRollbackFeatureActions = NULL; 959 rgRollbackFeatureActions = NULL;
960 960
961 hr = MsiEngineCalculateInstallUiLevel(display, pUserExperience, pPackage->sczId, FALSE, pAction->msiPackage.action, 961 hr = MsiEnginePlanPackageOptions(display, pUserExperience, pPackage->sczId, FALSE, pAction->msiPackage.action,
962 &pAction->msiPackage.actionMsiProperty, &pAction->msiPackage.uiLevel, &pAction->msiPackage.fDisableExternalUiHandler); 962 &pAction->msiPackage.actionMsiProperty, &pAction->msiPackage.uiLevel, &pAction->msiPackage.fDisableExternalUiHandler, &pAction->msiPackage.fileVersioning);
963 ExitOnFailure(hr, "Failed to get msi ui options."); 963 ExitOnFailure(hr, "Failed to get msi ui options.");
964 964
965 LoggingSetPackageVariable(pPackage, NULL, TRUE, pLog, pVariables, &pAction->msiPackage.sczLogPath); // ignore errors. 965 LoggingSetPackageVariable(pPackage, NULL, TRUE, pLog, pVariables, &pAction->msiPackage.sczLogPath); // ignore errors.
@@ -984,8 +984,8 @@ extern "C" HRESULT MsiEnginePlanAddPackage(
984 pAction->msiPackage.rgFeatures = rgFeatureActions; 984 pAction->msiPackage.rgFeatures = rgFeatureActions;
985 rgFeatureActions = NULL; 985 rgFeatureActions = NULL;
986 986
987 hr = MsiEngineCalculateInstallUiLevel(display, pUserExperience, pPackage->sczId, TRUE, pAction->msiPackage.action, 987 hr = MsiEnginePlanPackageOptions(display, pUserExperience, pPackage->sczId, TRUE, pAction->msiPackage.action,
988 &pAction->msiPackage.actionMsiProperty, &pAction->msiPackage.uiLevel, &pAction->msiPackage.fDisableExternalUiHandler); 988 &pAction->msiPackage.actionMsiProperty, &pAction->msiPackage.uiLevel, &pAction->msiPackage.fDisableExternalUiHandler, &pAction->msiPackage.fileVersioning);
989 ExitOnFailure(hr, "Failed to get msi ui options."); 989 ExitOnFailure(hr, "Failed to get msi ui options.");
990 990
991 LoggingSetPackageVariable(pPackage, NULL, FALSE, pLog, pVariables, &pAction->msiPackage.sczLogPath); // ignore errors. 991 LoggingSetPackageVariable(pPackage, NULL, FALSE, pLog, pVariables, &pAction->msiPackage.sczLogPath); // ignore errors.
@@ -1153,10 +1153,10 @@ extern "C" HRESULT MsiEngineExecutePackage(
1153 } 1153 }
1154 1154
1155 // set up properties 1155 // set up properties
1156 hr = MsiEngineConcatProperties(pPackage->Msi.rgProperties, pPackage->Msi.cProperties, pVariables, fRollback, &sczProperties, FALSE); 1156 hr = MsiEngineConcatPackageProperties(pPackage->Msi.rgProperties, pPackage->Msi.cProperties, pVariables, fRollback, &sczProperties, FALSE);
1157 ExitOnFailure(hr, "Failed to add properties to argument string."); 1157 ExitOnFailure(hr, "Failed to add properties to argument string.");
1158 1158
1159 hr = MsiEngineConcatProperties(pPackage->Msi.rgProperties, pPackage->Msi.cProperties, pVariables, fRollback, &sczObfuscatedProperties, TRUE); 1159 hr = MsiEngineConcatPackageProperties(pPackage->Msi.rgProperties, pPackage->Msi.cProperties, pVariables, fRollback, &sczObfuscatedProperties, TRUE);
1160 ExitOnFailure(hr, "Failed to add obfuscated properties to argument string."); 1160 ExitOnFailure(hr, "Failed to add obfuscated properties to argument string.");
1161 1161
1162 // add feature action properties 1162 // add feature action properties
@@ -1173,10 +1173,10 @@ extern "C" HRESULT MsiEngineExecutePackage(
1173 hr = ConcatPatchProperty(pCache, pPackage, fRollback, &sczObfuscatedProperties); 1173 hr = ConcatPatchProperty(pCache, pPackage, fRollback, &sczObfuscatedProperties);
1174 ExitOnFailure(hr, "Failed to add patch properties to obfuscated argument string."); 1174 ExitOnFailure(hr, "Failed to add patch properties to obfuscated argument string.");
1175 1175
1176 hr = MsiEngineConcatActionProperty(pExecuteAction->msiPackage.actionMsiProperty, &sczProperties); 1176 hr = MsiEngineConcatBurnProperties(pExecuteAction->msiPackage.action, pExecuteAction->msiPackage.actionMsiProperty, pExecuteAction->msiPackage.fileVersioning, TRUE, !pPackage->Msi.cFeatures, &sczProperties);
1177 ExitOnFailure(hr, "Failed to add action property to argument string."); 1177 ExitOnFailure(hr, "Failed to add action property to argument string.");
1178 1178
1179 hr = MsiEngineConcatActionProperty(pExecuteAction->msiPackage.actionMsiProperty, &sczObfuscatedProperties); 1179 hr = MsiEngineConcatBurnProperties(pExecuteAction->msiPackage.action, pExecuteAction->msiPackage.actionMsiProperty, pExecuteAction->msiPackage.fileVersioning, TRUE, !pPackage->Msi.cFeatures, &sczObfuscatedProperties);
1180 ExitOnFailure(hr, "Failed to add action property to obfuscated argument string."); 1180 ExitOnFailure(hr, "Failed to add action property to obfuscated argument string.");
1181 1181
1182 LogId(REPORT_STANDARD, MSG_APPLYING_PACKAGE, LoggingRollbackOrExecute(fRollback), pPackage->sczId, LoggingActionStateToString(pExecuteAction->msiPackage.action), sczMsiPath, sczObfuscatedProperties ? sczObfuscatedProperties : L""); 1182 LogId(REPORT_STANDARD, MSG_APPLYING_PACKAGE, LoggingRollbackOrExecute(fRollback), pPackage->sczId, LoggingActionStateToString(pExecuteAction->msiPackage.action), sczMsiPath, sczObfuscatedProperties ? sczObfuscatedProperties : L"");
@@ -1187,9 +1187,6 @@ extern "C" HRESULT MsiEngineExecutePackage(
1187 switch (pExecuteAction->msiPackage.action) 1187 switch (pExecuteAction->msiPackage.action)
1188 { 1188 {
1189 case BOOTSTRAPPER_ACTION_STATE_INSTALL: 1189 case BOOTSTRAPPER_ACTION_STATE_INSTALL:
1190 hr = StrAllocConcatSecure(&sczProperties, L" REBOOT=ReallySuppress", 0);
1191 ExitOnFailure(hr, "Failed to add reboot suppression property on install.");
1192
1193 hr = WiuInstallProduct(sczMsiPath, sczProperties, &restart); 1190 hr = WiuInstallProduct(sczMsiPath, sczProperties, &restart);
1194 ExitOnFailure(hr, "Failed to install MSI package."); 1191 ExitOnFailure(hr, "Failed to install MSI package.");
1195 1192
@@ -1197,17 +1194,6 @@ extern "C" HRESULT MsiEngineExecutePackage(
1197 break; 1194 break;
1198 1195
1199 case BOOTSTRAPPER_ACTION_STATE_MINOR_UPGRADE: 1196 case BOOTSTRAPPER_ACTION_STATE_MINOR_UPGRADE:
1200 // If feature selection is not enabled, then reinstall the existing features to ensure they get
1201 // updated.
1202 if (0 == pPackage->Msi.cFeatures)
1203 {
1204 hr = StrAllocConcatSecure(&sczProperties, L" REINSTALL=ALL", 0);
1205 ExitOnFailure(hr, "Failed to add reinstall all property on minor upgrade.");
1206 }
1207
1208 hr = StrAllocConcatSecure(&sczProperties, L" REINSTALLMODE=\"vomus\" REBOOT=ReallySuppress", 0);
1209 ExitOnFailure(hr, "Failed to add reinstall mode and reboot suppression properties on minor upgrade.");
1210
1211 hr = WiuInstallProduct(sczMsiPath, sczProperties, &restart); 1197 hr = WiuInstallProduct(sczMsiPath, sczProperties, &restart);
1212 ExitOnFailure(hr, "Failed to perform minor upgrade of MSI package."); 1198 ExitOnFailure(hr, "Failed to perform minor upgrade of MSI package.");
1213 1199
@@ -1217,31 +1203,11 @@ extern "C" HRESULT MsiEngineExecutePackage(
1217 case BOOTSTRAPPER_ACTION_STATE_MODIFY: __fallthrough; 1203 case BOOTSTRAPPER_ACTION_STATE_MODIFY: __fallthrough;
1218 case BOOTSTRAPPER_ACTION_STATE_MEND: __fallthrough; 1204 case BOOTSTRAPPER_ACTION_STATE_MEND: __fallthrough;
1219 case BOOTSTRAPPER_ACTION_STATE_REPAIR: 1205 case BOOTSTRAPPER_ACTION_STATE_REPAIR:
1220 {
1221 LPCWSTR wzReinstallAll = (BOOTSTRAPPER_ACTION_STATE_MODIFY == pExecuteAction->msiPackage.action ||
1222 pPackage->Msi.cFeatures) ? L"" : L" REINSTALL=ALL";
1223 LPCWSTR wzReinstallMode = (BOOTSTRAPPER_ACTION_STATE_MODIFY == pExecuteAction->msiPackage.action || BOOTSTRAPPER_ACTION_STATE_MEND == pExecuteAction->msiPackage.action) ? L"o" : L"e";
1224
1225 hr = StrAllocFormattedSecure(&sczProperties, L"%ls%ls REINSTALLMODE=\"cmus%ls\" REBOOT=ReallySuppress", sczProperties ? sczProperties : L"", wzReinstallAll, wzReinstallMode);
1226 ExitOnFailure(hr, "Failed to add reinstall mode and reboot suppression properties on repair.");
1227 }
1228
1229 // Ignore all dependencies, since the Burn engine already performed the check.
1230 hr = StrAllocFormattedSecure(&sczProperties, L"%ls %ls=ALL", sczProperties, DEPENDENCY_IGNOREDEPENDENCIES);
1231 ExitOnFailure(hr, "Failed to add the list of dependencies to ignore to the properties.");
1232
1233 hr = WiuInstallProduct(sczMsiPath, sczProperties, &restart); 1206 hr = WiuInstallProduct(sczMsiPath, sczProperties, &restart);
1234 ExitOnFailure(hr, "Failed to run maintenance mode for MSI package."); 1207 ExitOnFailure(hr, "Failed to run maintenance mode for MSI package.");
1235 break; 1208 break;
1236 1209
1237 case BOOTSTRAPPER_ACTION_STATE_UNINSTALL: 1210 case BOOTSTRAPPER_ACTION_STATE_UNINSTALL:
1238 hr = StrAllocConcatSecure(&sczProperties, L" REBOOT=ReallySuppress", 0);
1239 ExitOnFailure(hr, "Failed to add reboot suppression property on uninstall.");
1240
1241 // Ignore all dependencies, since the Burn engine already performed the check.
1242 hr = StrAllocFormattedSecure(&sczProperties, L"%ls %ls=ALL", sczProperties, DEPENDENCY_IGNOREDEPENDENCIES);
1243 ExitOnFailure(hr, "Failed to add the list of dependencies to ignore to the properties.");
1244
1245 hr = WiuConfigureProductEx(pPackage->Msi.sczProductCode, INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT, sczProperties, &restart); 1211 hr = WiuConfigureProductEx(pPackage->Msi.sczProductCode, INSTALLLEVEL_DEFAULT, INSTALLSTATE_ABSENT, sczProperties, &restart);
1246 if (HRESULT_FROM_WIN32(ERROR_UNKNOWN_PRODUCT) == hr) 1212 if (HRESULT_FROM_WIN32(ERROR_UNKNOWN_PRODUCT) == hr)
1247 { 1213 {
@@ -1283,13 +1249,55 @@ LExit:
1283 return hr; 1249 return hr;
1284} 1250}
1285 1251
1286extern "C" HRESULT MsiEngineConcatActionProperty( 1252extern "C" HRESULT MsiEngineConcatBurnProperties(
1253 __in BOOTSTRAPPER_ACTION_STATE action,
1287 __in BURN_MSI_PROPERTY actionMsiProperty, 1254 __in BURN_MSI_PROPERTY actionMsiProperty,
1255 __in BOOTSTRAPPER_MSI_FILE_VERSIONING fileVersioning,
1256 __in BOOL fMsiPackage,
1257 __in BOOL fFeatureSelectionEnabled,
1288 __deref_out_z LPWSTR* psczProperties 1258 __deref_out_z LPWSTR* psczProperties
1289 ) 1259 )
1290{ 1260{
1291 HRESULT hr = S_OK; 1261 HRESULT hr = S_OK;
1292 LPCWSTR wzPropertyName = NULL; 1262 LPCWSTR wzPropertyName = NULL;
1263 LPCWSTR wzReinstallModeOptions = NULL;
1264 LPCWSTR wzFileVersioning = L"";
1265 BOOL fReinstallAll = FALSE;
1266 BOOL fIgnoreDependencies = FALSE;
1267
1268 switch (action)
1269 {
1270 case BOOTSTRAPPER_ACTION_STATE_INSTALL:
1271 wzReinstallModeOptions = L"mus";
1272 break;
1273 case BOOTSTRAPPER_ACTION_STATE_MINOR_UPGRADE:
1274 if (fMsiPackage)
1275 {
1276 // If feature selection is not enabled,
1277 // then reinstall the existing features to ensure they get updated.
1278 fReinstallAll = !fFeatureSelectionEnabled;
1279
1280 wzReinstallModeOptions = L"vmus";
1281 }
1282 break;
1283 case BOOTSTRAPPER_ACTION_STATE_REPAIR: __fallthrough;
1284 case BOOTSTRAPPER_ACTION_STATE_MEND: __fallthrough;
1285 case BOOTSTRAPPER_ACTION_STATE_MODIFY:
1286 if (fMsiPackage)
1287 {
1288 fReinstallAll = BOOTSTRAPPER_ACTION_STATE_MODIFY != action && !fFeatureSelectionEnabled;
1289 wzReinstallModeOptions = L"cmus";
1290 fIgnoreDependencies = TRUE;
1291 }
1292 else
1293 {
1294 wzReinstallModeOptions = L"mus";
1295 }
1296 break;
1297 case BOOTSTRAPPER_ACTION_STATE_UNINSTALL:
1298 fIgnoreDependencies = TRUE;
1299 break;
1300 }
1293 1301
1294 switch (actionMsiProperty) 1302 switch (actionMsiProperty)
1295 { 1303 {
@@ -1313,11 +1321,46 @@ extern "C" HRESULT MsiEngineConcatActionProperty(
1313 ExitOnFailure(hr, "Failed to add burn action property."); 1321 ExitOnFailure(hr, "Failed to add burn action property.");
1314 } 1322 }
1315 1323
1324 if (fReinstallAll)
1325 {
1326 hr = StrAllocConcatSecure(psczProperties, L" REINSTALL=ALL", 0);
1327 ExitOnFailure(hr, "Failed to add reinstall all property.");
1328 }
1329
1330 if (wzReinstallModeOptions)
1331 {
1332 switch (fileVersioning)
1333 {
1334 case BOOTSTRAPPER_MSI_FILE_VERSIONING_MISSING_OR_OLDER:
1335 wzFileVersioning = L"o";
1336 break;
1337 case BOOTSTRAPPER_MSI_FILE_VERSIONING_MISSING_OR_OLDER_OR_EQUAL:
1338 wzFileVersioning = L"e";
1339 break;
1340 case BOOTSTRAPPER_MSI_FILE_VERSIONING_ALL:
1341 wzFileVersioning = L"a";
1342 break;
1343 }
1344
1345 hr = StrAllocConcatFormattedSecure(psczProperties, L" REINSTALLMODE=\"%ls%ls\"", wzReinstallModeOptions, wzFileVersioning);
1346 ExitOnFailure(hr, "Failed to add reinstall mode.");
1347 }
1348
1349 hr = StrAllocConcatSecure(psczProperties, L" REBOOT=ReallySuppress", 0);
1350 ExitOnFailure(hr, "Failed to add reboot suppression property.");
1351
1352 if (fIgnoreDependencies)
1353 {
1354 // Ignore all dependencies, since the Burn engine already performed the check.
1355 hr = StrAllocConcatFormattedSecure(psczProperties, L" %ls=ALL", DEPENDENCY_IGNOREDEPENDENCIES);
1356 ExitOnFailure(hr, "Failed to add the list of dependencies to ignore to the properties.");
1357 }
1358
1316LExit: 1359LExit:
1317 return hr; 1360 return hr;
1318} 1361}
1319 1362
1320extern "C" HRESULT MsiEngineConcatProperties( 1363extern "C" HRESULT MsiEngineConcatPackageProperties(
1321 __in_ecount(cProperties) BURN_MSIPROPERTY* rgProperties, 1364 __in_ecount(cProperties) BURN_MSIPROPERTY* rgProperties,
1322 __in DWORD cProperties, 1365 __in DWORD cProperties,
1323 __in BURN_VARIABLES* pVariables, 1366 __in BURN_VARIABLES* pVariables,
@@ -1379,7 +1422,7 @@ LExit:
1379 return hr; 1422 return hr;
1380} 1423}
1381 1424
1382extern "C" HRESULT MsiEngineCalculateInstallUiLevel( 1425extern "C" HRESULT MsiEnginePlanPackageOptions(
1383 __in BOOTSTRAPPER_DISPLAY display, 1426 __in BOOTSTRAPPER_DISPLAY display,
1384 __in BURN_USER_EXPERIENCE* pUserExperience, 1427 __in BURN_USER_EXPERIENCE* pUserExperience,
1385 __in LPCWSTR wzPackageId, 1428 __in LPCWSTR wzPackageId,
@@ -1387,11 +1430,13 @@ extern "C" HRESULT MsiEngineCalculateInstallUiLevel(
1387 __in BOOTSTRAPPER_ACTION_STATE actionState, 1430 __in BOOTSTRAPPER_ACTION_STATE actionState,
1388 __out BURN_MSI_PROPERTY* pActionMsiProperty, 1431 __out BURN_MSI_PROPERTY* pActionMsiProperty,
1389 __out INSTALLUILEVEL* pUiLevel, 1432 __out INSTALLUILEVEL* pUiLevel,
1390 __out BOOL* pfDisableExternalUiHandler 1433 __out BOOL* pfDisableExternalUiHandler,
1434 __out BOOTSTRAPPER_MSI_FILE_VERSIONING* pFileVersioning
1391 ) 1435 )
1392{ 1436{
1393 *pUiLevel = INSTALLUILEVEL_NONE; 1437 *pUiLevel = INSTALLUILEVEL_NONE;
1394 *pfDisableExternalUiHandler = FALSE; 1438 *pfDisableExternalUiHandler = FALSE;
1439 *pFileVersioning = BOOTSTRAPPER_MSI_FILE_VERSIONING_MISSING_OR_OLDER;
1395 1440
1396 if (BOOTSTRAPPER_DISPLAY_FULL == display || 1441 if (BOOTSTRAPPER_DISPLAY_FULL == display ||
1397 BOOTSTRAPPER_DISPLAY_PASSIVE == display) 1442 BOOTSTRAPPER_DISPLAY_PASSIVE == display)
@@ -1406,6 +1451,7 @@ extern "C" HRESULT MsiEngineCalculateInstallUiLevel(
1406 break; 1451 break;
1407 case BOOTSTRAPPER_ACTION_STATE_REPAIR: 1452 case BOOTSTRAPPER_ACTION_STATE_REPAIR:
1408 *pActionMsiProperty = BURN_MSI_PROPERTY_REPAIR; 1453 *pActionMsiProperty = BURN_MSI_PROPERTY_REPAIR;
1454 *pFileVersioning = BOOTSTRAPPER_MSI_FILE_VERSIONING_MISSING_OR_OLDER_OR_EQUAL;
1409 break; 1455 break;
1410 case BOOTSTRAPPER_ACTION_STATE_MODIFY: 1456 case BOOTSTRAPPER_ACTION_STATE_MODIFY:
1411 *pActionMsiProperty = BURN_MSI_PROPERTY_MODIFY; 1457 *pActionMsiProperty = BURN_MSI_PROPERTY_MODIFY;
@@ -1415,7 +1461,7 @@ extern "C" HRESULT MsiEngineCalculateInstallUiLevel(
1415 break; 1461 break;
1416 } 1462 }
1417 1463
1418 return UserExperienceOnPlanMsiPackage(pUserExperience, wzPackageId, fExecute, actionState, pActionMsiProperty, pUiLevel, pfDisableExternalUiHandler); 1464 return UserExperienceOnPlanMsiPackage(pUserExperience, wzPackageId, fExecute, actionState, pActionMsiProperty, pUiLevel, pfDisableExternalUiHandler, pFileVersioning);
1419} 1465}
1420 1466
1421extern "C" void MsiEngineUpdateInstallRegistrationState( 1467extern "C" void MsiEngineUpdateInstallRegistrationState(