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 0410df9 commit 9d89558
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ This repository contains the PanelSwWix4: A custom WiX Toolset codebase
- ExePackage/@DetectVersionVariable: Support using one of the XxxSearch elements to provide a version number in a variable to test against the package's version.
- [7778](https://github.com/wixtoolset/issues/issues/7778): Bundle/@Wix3DependencyMode=yes/no. If yes, then default MSI/MSP provider key uses the ProductCode/PatchCode. Use only if a WiX4 bundle chains packages of a WiX3 bundle.
- [4889](https://github.com/wixtoolset/issues/issues/4889): Support custom container compressions using bundle extensions
- Not overwriting log files when retrying to execute a package
4 changes: 4 additions & 0 deletions src/burn/engine/apply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2477,6 +2477,10 @@ static HRESULT DoExecuteAction(
do
{
fInsideMsiTransaction = ppMsiTransaction && *ppMsiTransaction && (*ppMsiTransaction)->fActive;
if (fRetry)
{
LoggingPromoteLogFile(pExecuteAction, &pEngineState->variables);
}
fRetry = FALSE;

switch (pExecuteAction->type)
Expand Down
86 changes: 86 additions & 0 deletions src/burn/engine/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,92 @@ extern "C" HRESULT LoggingSetCompatiblePackageVariable(
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_RELATED_BUNDLE:
sczLogPathVariable = pExecuteAction->relatedBundle.pRelatedBundle->package.sczLogPathVariable;
break;
case BURN_EXECUTE_ACTION_TYPE_BUNDLE_PACKAGE:
sczLogPathVariable = pExecuteAction->bundlePackage.pPackage->sczLogPathVariable;
break;
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;
case BURN_EXECUTE_ACTION_TYPE_UNINSTALL_MSI_COMPATIBLE_PACKAGE:
sczLogPathVariable = pExecuteAction->uninstallMsiCompatiblePackage.pParentPackage->sczCompatibleLogPathVariable;
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;
case BURN_EXECUTE_ACTION_TYPE_UNINSTALL_MSI_COMPATIBLE_PACKAGE:
ReleaseStr(pExecuteAction->uninstallMsiCompatiblePackage.sczLogPath);
pExecuteAction->uninstallMsiCompatiblePackage.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 @@ -65,6 +65,11 @@ HRESULT LoggingSetCompatiblePackageVariable(
__out_opt LPWSTR* psczLogPath
);

HRESULT LoggingPromoteLogFile(
__in BURN_EXECUTE_ACTION* pExecuteAction,
__in BURN_VARIABLES* pVariables
);

HRESULT LoggingSetPackageVariable(
__in BURN_PACKAGE* pPackage,
__in_z_opt LPCWSTR wzSuffix,
Expand Down
2 changes: 1 addition & 1 deletion src/wix/WixToolset.Sdk/tools/wix.targets
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,6 @@
<ImportGroup>
<Import Project="$(MSBuildUserExtensionsPath)\WixToolset\$(WixToolsetMajorMinorVersion)\Imports\WixToolset.targets\ImportAfter\*" Condition="'$(ImportUserLocationsByWildcardAfterWixToolsetTargets)' != 'false' and Exists('$(MSBuildUserExtensionsPath)\WixToolset\$(WixToolsetMajorMinorVersion)\Imports\WixToolset.targets\ImportAfter')" />
<Import Project="$(MSBuildExtensionsPath)\WixToolset\$(WixToolsetMajorMinorVersion)\Imports\WixToolset.targets\ImportAfter\*" Condition="'$(ImportByWildcardAfterWixToolsetTargets)' != 'false' and Exists('$(MSBuildExtensionsPath)\WixToolset\$(WixToolsetMajorMinorVersion)\Imports\WixToolset.targets\ImportAfter')" />
<Import Project="$(MSBuildExtensionsPath)\FireGiant\HeatWave\FireGiant.HeatWave.DesignTime.targets" Condition="'$(ImportByWildcardAfterWixToolsetTargets)' != 'false' and Exists('$(MSBuildExtensionsPath)\FireGiant\HeatWave\FireGiant.HeatWave.DesignTime.targets')" />
<Import Project="$(MSBuildExtensionsPath)\FireGiant\HeatWave\FireGiant.HeatWave.DesignTime.targets" Condition="'$(ImportByWildcardAfterWixToolsetTargets)' != 'false' and Exists('$(MSBuildExtensionsPath)\FireGiant\HeatWave\FireGiant.HeatWave.DesignTime.targets') and ('$(FireGiantHeatWaveBuildTasksAssembly)' == '' or !Exists('$(FireGiantHeatWaveBuildTasksAssembly)'))" />
</ImportGroup>
</Project>

0 comments on commit 9d89558

Please sign in to comment.