diff --git a/Readme.md b/Readme.md index 5c564d2b..04aaf411 100644 --- a/Readme.md +++ b/Readme.md @@ -34,6 +34,7 @@ - wixstdba: Specifying "-forcerestart' on the command line forces reboot at the end of the installation - Changes by WiX up to git commit 376423b8101f4b59ee865e8a255cfe190fa5a7f1 - Build for .NET Framework 4.0 +- Not overwriting log files when retrying to execute a package # WiX Toolset on GitHub The WiX Toolset builds Windows installation packages from XML source code. The toolset supports a command-line environment that developers may integrate into their build processes to build Windows Installer (MSI) packages and executable bundles. The WiX GitHub project hosts the WiX source code Git repositories. The following links will take you to more details: diff --git a/src/burn/engine/apply.cpp b/src/burn/engine/apply.cpp index 84a3c0f6..481c9226 100644 --- a/src/burn/engine/apply.cpp +++ b/src/burn/engine/apply.cpp @@ -1883,6 +1883,12 @@ static HRESULT DoExecuteAction( do { + if (fRetry) + { + LoggingPromoteLogFile(pExecuteAction, &pEngineState->variables); + fRetry = FALSE; + } + switch (pExecuteAction->type) { case BURN_EXECUTE_ACTION_TYPE_CHECKPOINT: diff --git a/src/burn/engine/logging.cpp b/src/burn/engine/logging.cpp index 86d51ec6..240cada8 100644 --- a/src/burn/engine/logging.cpp +++ b/src/burn/engine/logging.cpp @@ -255,6 +255,78 @@ extern "C" HRESULT LoggingSetMsiTransactionVariable( return hr; } +HRESULT LoggingPromoteLogFile( + __in BURN_EXECUTE_ACTION* pExecuteAction, + __in BURN_VARIABLES* pVariables + ) +{ + HRESULT hr = S_OK; + LPWSTR sczLogPath = NULL; + LPWSTR sczNewLogPath = NULL; + LPCWSTR sczLogPathVariable = NULL; + + switch (pExecuteAction->type) + { + case BURN_EXECUTE_ACTION_TYPE_EXE_PACKAGE: + sczLogPathVariable = pExecuteAction->exePackage.pPackage->sczLogPathVariable; + break; + case BURN_EXECUTE_ACTION_TYPE_MSI_PACKAGE: + sczLogPathVariable = pExecuteAction->msiPackage.pPackage->sczLogPathVariable; + break; + case BURN_EXECUTE_ACTION_TYPE_MSP_TARGET: + sczLogPathVariable = pExecuteAction->mspTarget.pPackage->sczLogPathVariable; + break; + case BURN_EXECUTE_ACTION_TYPE_MSU_PACKAGE: + sczLogPathVariable = pExecuteAction->msuPackage.pPackage->sczLogPathVariable; + break; + } + + if (!sczLogPathVariable || !*sczLogPathVariable) + { + hr = S_FALSE; + ExitFunction(); + } + + hr = VariableGetFormatted(pVariables, sczLogPathVariable, &sczLogPath, NULL); + if ((hr == E_NOTFOUND) || !sczLogPath || !*sczLogPath) + { + hr = S_FALSE; + ExitFunction(); + } + ExitOnFailure(hr, "Failed to get log path."); + + hr = FileAddSuffixToBaseName(sczLogPath, L"_", &sczNewLogPath); + ExitOnFailure(hr, "Failed to append to log path."); + + hr = VariableSetString(pVariables, sczLogPathVariable, sczNewLogPath, FALSE, FALSE); + ExitOnFailure(hr, "Failed to set log path into variable."); + + switch (pExecuteAction->type) + { + case BURN_EXECUTE_ACTION_TYPE_MSI_PACKAGE: + ReleaseStr(pExecuteAction->msiPackage.sczLogPath); + pExecuteAction->msiPackage.sczLogPath = sczNewLogPath; + sczNewLogPath = NULL; + break; + case BURN_EXECUTE_ACTION_TYPE_MSP_TARGET: + ReleaseStr(pExecuteAction->mspTarget.sczLogPath); + pExecuteAction->mspTarget.sczLogPath = sczNewLogPath; + sczNewLogPath = NULL; + break; + case BURN_EXECUTE_ACTION_TYPE_MSU_PACKAGE: + ReleaseStr(pExecuteAction->msuPackage.sczLogPath); + pExecuteAction->msuPackage.sczLogPath = sczNewLogPath; + sczNewLogPath = NULL; + break; + } + +LExit: + ReleaseStr(sczLogPath); + ReleaseStr(sczNewLogPath); + + return hr; +} + extern "C" HRESULT LoggingSetPackageVariable( __in BURN_PACKAGE* pPackage, __in_z_opt LPCWSTR wzSuffix, diff --git a/src/burn/engine/logging.h b/src/burn/engine/logging.h index b4500b48..d5d12035 100644 --- a/src/burn/engine/logging.h +++ b/src/burn/engine/logging.h @@ -59,6 +59,11 @@ HRESULT LoggingSetMsiTransactionVariable( __in BURN_VARIABLES* pVariables ); +HRESULT LoggingPromoteLogFile( + __in BURN_EXECUTE_ACTION* pExecuteAction, + __in BURN_VARIABLES* pVariables + ); + HRESULT LoggingSetPackageVariable( __in BURN_PACKAGE* pPackage, __in_z_opt LPCWSTR wzSuffix,