Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIXFEAT:3736 - Add burn variable to cache path #52

Merged
merged 2 commits into from Jun 2, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions History.md
@@ -1,3 +1,5 @@
* SeanHall: WIXFEAT:3736 - Add WixBundleExecutePackageCacheFolder variable.

* RobMen: WIXBUG:4288 - do not mask error code when testing file size of payload in cache.

* RobMen: Point to new page for linker error 217 to fix WIXBUG:4208.
Expand Down
1 change: 1 addition & 0 deletions src/burn/engine/core.h
Expand Up @@ -46,6 +46,7 @@ const LPCWSTR BURN_COMMANDLINE_SWITCH_PREFIX = L"burn.";
const LPCWSTR BURN_BUNDLE_LAYOUT_DIRECTORY = L"WixBundleLayoutDirectory";
const LPCWSTR BURN_BUNDLE_ACTION = L"WixBundleAction";
const LPCWSTR BURN_BUNDLE_ACTIVE_PARENT = L"WixBundleActiveParent";
const LPCWSTR BURN_BUNDLE_EXECUTE_PACKAGE_CACHE_FOLDER = L"WixBundleExecutePackageCacheFolder";
const LPCWSTR BURN_BUNDLE_FORCED_RESTART_PACKAGE = L"WixBundleForcedRestartPackage";
const LPCWSTR BURN_BUNDLE_INSTALLED = L"WixBundleInstalled";
const LPCWSTR BURN_BUNDLE_ELEVATED = L"WixBundleElevated";
Expand Down
6 changes: 4 additions & 2 deletions src/burn/engine/elevation.cpp
Expand Up @@ -193,6 +193,7 @@ static HRESULT OnExecuteMspPackage(
static HRESULT OnExecuteMsuPackage(
__in HANDLE hPipe,
__in BURN_PACKAGES* pPackages,
__in BURN_VARIABLES* pVariables,
__in BYTE* pbData,
__in DWORD cbData
);
Expand Down Expand Up @@ -1383,7 +1384,7 @@ static HRESULT ProcessElevatedChildMessage(
break;

case BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_MSU_PACKAGE:
hrResult = OnExecuteMsuPackage(pContext->hPipe, pContext->pPackages, (BYTE*)pMsg->pvData, pMsg->cbData);
hrResult = OnExecuteMsuPackage(pContext->hPipe, pContext->pPackages, pContext->pVariables, (BYTE*)pMsg->pvData, pMsg->cbData);
break;

case BURN_ELEVATION_MESSAGE_TYPE_EXECUTE_PACKAGE_PROVIDER:
Expand Down Expand Up @@ -2125,6 +2126,7 @@ static HRESULT OnExecuteMspPackage(
static HRESULT OnExecuteMsuPackage(
__in HANDLE hPipe,
__in BURN_PACKAGES* pPackages,
__in BURN_VARIABLES* pVariables,
__in BYTE* pbData,
__in DWORD cbData
)
Expand Down Expand Up @@ -2159,7 +2161,7 @@ static HRESULT OnExecuteMsuPackage(
ExitOnFailure1(hr, "Failed to find package: %ls", sczPackage);

// execute MSU package
hr = MsuEngineExecutePackage(&executeAction, static_cast<BOOL>(dwRollback), static_cast<BOOL>(dwStopWusaService), GenericExecuteMessageHandler, hPipe, &restart);
hr = MsuEngineExecutePackage(&executeAction, pVariables, static_cast<BOOL>(dwRollback), static_cast<BOOL>(dwStopWusaService), GenericExecuteMessageHandler, hPipe, &restart);
ExitOnFailure(hr, "Failed to execute MSU package.");

LExit:
Expand Down
9 changes: 9 additions & 0 deletions src/burn/engine/exeengine.cpp
Expand Up @@ -441,6 +441,12 @@ extern "C" HRESULT ExeEngineExecutePackage(
hr = CacheGetCompletedPath(pExecuteAction->exePackage.pPackage->fPerMachine, pExecuteAction->exePackage.pPackage->sczCacheId, &sczCachedDirectory);
ExitOnFailure1(hr, "Failed to get cached path for package: %ls", pExecuteAction->exePackage.pPackage->sczId);

hr = PathBackslashTerminate(&sczCachedDirectory);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it would be better to do this in the function that would set sczCachedDirectory rather than force a reallocation (probably) just for a variable value.

ExitOnFailure(hr, "Failed to backslashify.");

// Best effort to set the execute package cache folder variable.
VariableSetString(pVariables, BURN_BUNDLE_EXECUTE_PACKAGE_CACHE_FOLDER, sczCachedDirectory, TRUE);

hr = PathConcat(sczCachedDirectory, pExecuteAction->exePackage.pPackage->rgPayloads[0].pPayload->sczFilePath, &sczExecutablePath);
ExitOnFailure(hr, "Failed to build executable path.");

Expand Down Expand Up @@ -580,6 +586,9 @@ extern "C" HRESULT ExeEngineExecutePackage(
ReleaseHandle(pi.hThread);
ReleaseHandle(pi.hProcess);

// Best effort to clear the execute package cache folder variable.
VariableSetString(pVariables, BURN_BUNDLE_EXECUTE_PACKAGE_CACHE_FOLDER, NULL, TRUE);

return hr;
}

Expand Down
9 changes: 9 additions & 0 deletions src/burn/engine/msiengine.cpp
Expand Up @@ -1122,6 +1122,12 @@ extern "C" HRESULT MsiEngineExecutePackage(
hr = CacheGetCompletedPath(pExecuteAction->msiPackage.pPackage->fPerMachine, pExecuteAction->msiPackage.pPackage->sczCacheId, &sczCachedDirectory);
ExitOnFailure1(hr, "Failed to get cached path for package: %ls", pExecuteAction->msiPackage.pPackage->sczId);

hr = PathBackslashTerminate(&sczCachedDirectory);
ExitOnFailure(hr, "Failed to backslashify.");

// Best effort to set the execute package cache folder variable.
VariableSetString(pVariables, BURN_BUNDLE_EXECUTE_PACKAGE_CACHE_FOLDER, sczCachedDirectory, TRUE);

hr = PathConcat(sczCachedDirectory, pExecuteAction->msiPackage.pPackage->rgPayloads[0].pPayload->sczFilePath, &sczMsiPath);
ExitOnFailure(hr, "Failed to build MSI path.");
}
Expand Down Expand Up @@ -1259,6 +1265,9 @@ extern "C" HRESULT MsiEngineExecutePackage(
break;
}

// Best effort to clear the execute package cache folder variable.
VariableSetString(pVariables, BURN_BUNDLE_EXECUTE_PACKAGE_CACHE_FOLDER, NULL, TRUE);

return hr;
}

Expand Down
9 changes: 9 additions & 0 deletions src/burn/engine/mspengine.cpp
Expand Up @@ -473,6 +473,12 @@ extern "C" HRESULT MspEngineExecutePackage(
hr = CacheGetCompletedPath(pMspPackage->fPerMachine, pMspPackage->sczCacheId, &sczCachedDirectory);
ExitOnFailure1(hr, "Failed to get cached path for MSP package: %ls", pMspPackage->sczId);

hr = PathBackslashTerminate(&sczCachedDirectory);
ExitOnFailure(hr, "Failed to backslashify.");

// Best effort to set the execute package cache folder variable.
VariableSetString(pVariables, BURN_BUNDLE_EXECUTE_PACKAGE_CACHE_FOLDER, sczCachedDirectory, TRUE);

hr = PathConcat(sczCachedDirectory, pMspPackage->rgPayloads[0].pPayload->sczFilePath, &sczMspPath);
ExitOnFailure(hr, "Failed to build MSP path.");

Expand Down Expand Up @@ -574,6 +580,9 @@ extern "C" HRESULT MspEngineExecutePackage(
break;
}

// Best effort to clear the execute package cache folder variable.
VariableSetString(pVariables, BURN_BUNDLE_EXECUTE_PACKAGE_CACHE_FOLDER, NULL, TRUE);

return hr;
}

Expand Down
10 changes: 10 additions & 0 deletions src/burn/engine/msuengine.cpp
Expand Up @@ -249,6 +249,7 @@ extern "C" HRESULT MsuEnginePlanAddPackage(

extern "C" HRESULT MsuEngineExecutePackage(
__in BURN_EXECUTE_ACTION* pExecuteAction,
__in BURN_VARIABLES* pVariables,
__in BOOL fRollback,
__in BOOL fStopWusaService,
__in PFN_GENERICMESSAGEHANDLER pfnGenericMessageHandler,
Expand Down Expand Up @@ -305,6 +306,12 @@ extern "C" HRESULT MsuEngineExecutePackage(
hr = CacheGetCompletedPath(TRUE, pExecuteAction->msuPackage.pPackage->sczCacheId, &sczCachedDirectory);
ExitOnFailure1(hr, "Failed to get cached path for package: %ls", pExecuteAction->msuPackage.pPackage->sczId);

hr = PathBackslashTerminate(&sczCachedDirectory);
ExitOnFailure(hr, "Failed to backslashify.");

// Best effort to set the execute package cache folder variable.
VariableSetString(pVariables, BURN_BUNDLE_EXECUTE_PACKAGE_CACHE_FOLDER, sczCachedDirectory, TRUE);

hr = PathConcat(sczCachedDirectory, pExecuteAction->msuPackage.pPackage->rgPayloads[0].pPayload->sczFilePath, &sczMsuPath);
ExitOnFailure(hr, "Failed to build MSU path.");

Expand Down Expand Up @@ -411,6 +418,9 @@ extern "C" HRESULT MsuEngineExecutePackage(
SetServiceStartType(schWu, SERVICE_DISABLED);
}

// Best effort to clear the execute package cache folder variable.
VariableSetString(pVariables, BURN_BUNDLE_EXECUTE_PACKAGE_CACHE_FOLDER, NULL, TRUE);

return hr;
}

Expand Down
1 change: 1 addition & 0 deletions src/burn/engine/msuengine.h
Expand Up @@ -45,6 +45,7 @@ HRESULT MsuEnginePlanAddPackage(
);
HRESULT MsuEngineExecutePackage(
__in BURN_EXECUTE_ACTION* pExecuteAction,
__in BURN_VARIABLES* pVariables,
__in BOOL fRollback,
__in BOOL fStopWusaService,
__in PFN_GENERICMESSAGEHANDLER pfnGenericMessageHandler,
Expand Down
1 change: 1 addition & 0 deletions src/burn/engine/variable.cpp
Expand Up @@ -265,6 +265,7 @@ extern "C" HRESULT VariableInitialize(
{L"WindowsFolder", InitializeVariableCsidlFolder, CSIDL_WINDOWS},
{L"WindowsVolume", InitializeVariableWindowsVolumeFolder, 0},
{BURN_BUNDLE_ACTION, InitializeVariableNumeric, 0},
{BURN_BUNDLE_EXECUTE_PACKAGE_CACHE_FOLDER, InitializeVariableString, NULL},
{BURN_BUNDLE_FORCED_RESTART_PACKAGE, InitializeVariableString, NULL, TRUE},
{BURN_BUNDLE_INSTALLED, InitializeVariableNumeric, 0},
{BURN_BUNDLE_ELEVATED, InitializeVariableNumeric, 0},
Expand Down
1 change: 1 addition & 0 deletions src/chm/documents/bundle/bundle_built_in_variables.html.md
Expand Up @@ -58,6 +58,7 @@ The Burn engine offers a set of commonly-used variables so you can use them with
* WixBundleAction - set to the numeric value of BOOTSTRAPPER\_ACTION from the command-line and updated during the call to IBootstrapperEngine::Plan().
* WixBundleDirectoryLayout - set to the folder provided to the -layout switch (default is the directory containing the bundle executable). This variable can also be set by the bootstrapper application to modify where files will be laid out.
* WixBundleElevated - gets whether the bundle was launched elevated and will be set to 1 once the bundle is elevated. For example, use this variable to show or hide the elevation shield in the bootstrapper application UI.
* WixBundleExecutePackageCacheFolder - gets the absolute path to the currently executing package&apos;s cache folder. This variable is only available while the package is executing.
* WixBundleForcedRestartPackage - gets the ID of the package that caused a force restart during apply. This value is reset on the next call to apply.
* WixBundleInstalled - gets whether the bundle was already installed. This value is only set when the engine initializes.
* WixBundleLastUsedSource - gets the path of the last successful source resolution for a container or payload.
Expand Down