Skip to content

Commit eef4ae2

Browse files
committed
Not overwriting log files when retrying to execute a package
Creating a new log file with a '_' appended to the previous file name before the extension
1 parent 99e754b commit eef4ae2

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed

Readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
- wixstdba: Specifying "-forcerestart' on the command line forces reboot at the end of the installation
3535
- Changes by WiX up to git commit 376423b8101f4b59ee865e8a255cfe190fa5a7f1
3636
- Build for .NET Framework 4.0
37+
- Not overwriting log files when retrying to execute a package
3738

3839
# WiX Toolset on GitHub
3940
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:

src/burn/engine/apply.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,6 +1883,12 @@ static HRESULT DoExecuteAction(
18831883

18841884
do
18851885
{
1886+
if (fRetry)
1887+
{
1888+
LoggingPromoteLogFile(pExecuteAction, &pEngineState->variables);
1889+
fRetry = FALSE;
1890+
}
1891+
18861892
switch (pExecuteAction->type)
18871893
{
18881894
case BURN_EXECUTE_ACTION_TYPE_CHECKPOINT:

src/burn/engine/logging.cpp

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,78 @@ extern "C" HRESULT LoggingSetMsiTransactionVariable(
255255
return hr;
256256
}
257257

258+
HRESULT LoggingPromoteLogFile(
259+
__in BURN_EXECUTE_ACTION* pExecuteAction,
260+
__in BURN_VARIABLES* pVariables
261+
)
262+
{
263+
HRESULT hr = S_OK;
264+
LPWSTR sczLogPath = NULL;
265+
LPWSTR sczNewLogPath = NULL;
266+
LPCWSTR sczLogPathVariable = NULL;
267+
268+
switch (pExecuteAction->type)
269+
{
270+
case BURN_EXECUTE_ACTION_TYPE_EXE_PACKAGE:
271+
sczLogPathVariable = pExecuteAction->exePackage.pPackage->sczLogPathVariable;
272+
break;
273+
case BURN_EXECUTE_ACTION_TYPE_MSI_PACKAGE:
274+
sczLogPathVariable = pExecuteAction->msiPackage.pPackage->sczLogPathVariable;
275+
break;
276+
case BURN_EXECUTE_ACTION_TYPE_MSP_TARGET:
277+
sczLogPathVariable = pExecuteAction->mspTarget.pPackage->sczLogPathVariable;
278+
break;
279+
case BURN_EXECUTE_ACTION_TYPE_MSU_PACKAGE:
280+
sczLogPathVariable = pExecuteAction->msuPackage.pPackage->sczLogPathVariable;
281+
break;
282+
}
283+
284+
if (!sczLogPathVariable || !*sczLogPathVariable)
285+
{
286+
hr = S_FALSE;
287+
ExitFunction();
288+
}
289+
290+
hr = VariableGetFormatted(pVariables, sczLogPathVariable, &sczLogPath);
291+
if ((hr == E_NOTFOUND) || !sczLogPath || !*sczLogPath)
292+
{
293+
hr = S_FALSE;
294+
ExitFunction();
295+
}
296+
ExitOnFailure(hr, "Failed to get log path.");
297+
298+
hr = FileAddSuffixToBaseName(sczLogPath, L"_", &sczNewLogPath);
299+
ExitOnFailure(hr, "Failed to append to log path.");
300+
301+
hr = VariableSetString(pVariables, sczLogPathVariable, sczNewLogPath, FALSE);
302+
ExitOnFailure(hr, "Failed to set log path into variable.");
303+
304+
switch (pExecuteAction->type)
305+
{
306+
case BURN_EXECUTE_ACTION_TYPE_MSI_PACKAGE:
307+
ReleaseStr(pExecuteAction->msiPackage.sczLogPath);
308+
pExecuteAction->msiPackage.sczLogPath = sczNewLogPath;
309+
sczNewLogPath = NULL;
310+
break;
311+
case BURN_EXECUTE_ACTION_TYPE_MSP_TARGET:
312+
ReleaseStr(pExecuteAction->mspTarget.sczLogPath);
313+
pExecuteAction->mspTarget.sczLogPath = sczNewLogPath;
314+
sczNewLogPath = NULL;
315+
break;
316+
case BURN_EXECUTE_ACTION_TYPE_MSU_PACKAGE:
317+
ReleaseStr(pExecuteAction->msuPackage.sczLogPath);
318+
pExecuteAction->msuPackage.sczLogPath = sczNewLogPath;
319+
sczNewLogPath = NULL;
320+
break;
321+
}
322+
323+
LExit:
324+
ReleaseStr(sczLogPath);
325+
ReleaseStr(sczNewLogPath);
326+
327+
return hr;
328+
}
329+
258330
extern "C" HRESULT LoggingSetPackageVariable(
259331
__in BURN_PACKAGE* pPackage,
260332
__in_z_opt LPCWSTR wzSuffix,

src/burn/engine/logging.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ HRESULT LoggingSetMsiTransactionVariable(
5959
__in BURN_VARIABLES* pVariables
6060
);
6161

62+
HRESULT LoggingPromoteLogFile(
63+
__in BURN_EXECUTE_ACTION* pExecuteAction,
64+
__in BURN_VARIABLES* pVariables
65+
);
66+
6267
HRESULT LoggingSetPackageVariable(
6368
__in BURN_PACKAGE* pPackage,
6469
__in_z_opt LPCWSTR wzSuffix,

0 commit comments

Comments
 (0)