Skip to content

Commit

Permalink
Not overwriting log files when retrying to execute a package
Browse files Browse the repository at this point in the history
Creating a new log file with a '_' appended to the previous file name before the extension
  • Loading branch information
nirbar committed May 2, 2024
1 parent 99e754b commit cac9f6f
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions src/burn/engine/apply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
72 changes: 72 additions & 0 deletions src/burn/engine/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions src/burn/engine/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit cac9f6f

Please sign in to comment.