Skip to content
/ wix Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/burn/engine/apply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2761,7 +2761,7 @@ static HRESULT ExecuteRelatedBundle(
}
else
{
hrExecute = BundlePackageEngineExecuteRelatedBundle(pExecuteAction, pContext->pCache, &pEngineState->variables, fRollback, GenericExecuteMessageHandler, pContext, pRestart);
hrExecute = BundlePackageEngineExecuteRelatedBundle(pExecuteAction, pContext->pCache, &pEngineState->variables, fRollback, FALSE/*fPerMachine*/, GenericExecuteMessageHandler, pContext, pRestart);
ExitOnFailure(hrExecute, "Failed to configure per-user related bundle.");
}

Expand Down Expand Up @@ -2888,7 +2888,7 @@ static HRESULT ExecuteBundlePackage(
}
else
{
hrExecute = BundlePackageEngineExecutePackage(pExecuteAction, pContext->pCache, &pEngineState->variables, fRollback, SUCCEEDED(pExecuteAction->bundlePackage.pPackage->hrCacheResult), GenericExecuteMessageHandler, pContext, pRestart);
hrExecute = BundlePackageEngineExecutePackage(pExecuteAction, pContext->pCache, &pEngineState->variables, fRollback, SUCCEEDED(pExecuteAction->bundlePackage.pPackage->hrCacheResult), pEngineState->registration.fPerMachine, GenericExecuteMessageHandler, pContext, pRestart);
ExitOnFailure(hrExecute, "Failed to configure per-user BUNDLE package.");
}

Expand Down
24 changes: 21 additions & 3 deletions src/burn/engine/bundlepackageengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ static HRESULT ExecuteBundle(
__in BOOTSTRAPPER_RELATION_TYPE relationType,
__in BURN_PACKAGE* pPackage,
__in BOOL fPseudoPackage,
__in BOOL fPerMachine,
__in_z_opt LPCWSTR wzParent,
__in_z_opt LPCWSTR wzIgnoreDependencies,
__in_z_opt LPCWSTR wzAncestors,
Expand All @@ -51,7 +52,7 @@ extern "C" HRESULT BundlePackageEngineParsePackageFromXml(
BOOL fFoundXml = FALSE;
LPWSTR scz = NULL;

// @DetectCondition
// @BundleCode
hr = XmlGetAttributeEx(pixnBundlePackage, L"BundleCode", &pPackage->Bundle.sczBundleCode);
ExitOnRequiredXmlQueryFailure(hr, "Failed to get @BundleCode.");

Expand Down Expand Up @@ -91,6 +92,10 @@ extern "C" HRESULT BundlePackageEngineParsePackageFromXml(
hr = XmlGetYesNoAttribute(pixnBundlePackage, L"Win64", &pPackage->Bundle.fWin64);
ExitOnRequiredXmlQueryFailure(hr, "Failed to get @Win64.");

// @Scope
hr = PackageParseScopeFromXml(pixnBundlePackage, &pPackage->scope);
ExitOnRequiredXmlQueryFailure(hr, "Failed to get @Scope.");

hr = BundlePackageEngineParseRelatedCodes(pixnBundlePackage, &pPackage->Bundle.rgsczDetectCodes, &pPackage->Bundle.cDetectCodes, &pPackage->Bundle.rgsczUpgradeCodes, &pPackage->Bundle.cUpgradeCodes, &pPackage->Bundle.rgsczAddonCodes, &pPackage->Bundle.cAddonCodes, &pPackage->Bundle.rgsczPatchCodes, &pPackage->Bundle.cPatchCodes);
ExitOnFailure(hr, "Failed to parse related codes.");

Expand Down Expand Up @@ -608,6 +613,7 @@ extern "C" HRESULT BundlePackageEngineExecutePackage(
__in BURN_VARIABLES* pVariables,
__in BOOL fRollback,
__in BOOL fCacheAvailable,
__in BOOL fPerMachine,
__in PFN_GENERICMESSAGEHANDLER pfnGenericMessageHandler,
__in LPVOID pvContext,
__out BOOTSTRAPPER_APPLY_RESTART* pRestart
Expand All @@ -621,14 +627,15 @@ extern "C" HRESULT BundlePackageEngineExecutePackage(
BOOTSTRAPPER_RELATION_TYPE relationType = BOOTSTRAPPER_RELATION_CHAIN_PACKAGE;
BURN_PACKAGE* pPackage = pExecuteAction->bundlePackage.pPackage;

return ExecuteBundle(pCache, pVariables, fRollback, fCacheAvailable, pfnGenericMessageHandler, pvContext, action, relationType, pPackage, FALSE, wzParent, wzIgnoreDependencies, wzAncestors, wzEngineWorkingDirectory, pRestart);
return ExecuteBundle(pCache, pVariables, fRollback, fCacheAvailable, pfnGenericMessageHandler, pvContext, action, relationType, pPackage, FALSE, fPerMachine, wzParent, wzIgnoreDependencies, wzAncestors, wzEngineWorkingDirectory, pRestart);
}

extern "C" HRESULT BundlePackageEngineExecuteRelatedBundle(
__in BURN_EXECUTE_ACTION* pExecuteAction,
__in BURN_CACHE* pCache,
__in BURN_VARIABLES* pVariables,
__in BOOL fRollback,
__in BOOL fPerMachine,
__in PFN_GENERICMESSAGEHANDLER pfnGenericMessageHandler,
__in LPVOID pvContext,
__out BOOTSTRAPPER_APPLY_RESTART* pRestart
Expand All @@ -643,7 +650,7 @@ extern "C" HRESULT BundlePackageEngineExecuteRelatedBundle(
BOOTSTRAPPER_RELATION_TYPE relationType = ConvertRelationType(pRelatedBundle->planRelationType);
BURN_PACKAGE* pPackage = &pRelatedBundle->package;

return ExecuteBundle(pCache, pVariables, fRollback, TRUE, pfnGenericMessageHandler, pvContext, action, relationType, pPackage, TRUE, wzParent, wzIgnoreDependencies, wzAncestors, wzEngineWorkingDirectory, pRestart);
return ExecuteBundle(pCache, pVariables, fRollback, TRUE, pfnGenericMessageHandler, pvContext, action, relationType, pPackage, TRUE, fPerMachine, wzParent, wzIgnoreDependencies, wzAncestors, wzEngineWorkingDirectory, pRestart);
}

extern "C" void BundlePackageEngineUpdateInstallRegistrationState(
Expand Down Expand Up @@ -742,6 +749,7 @@ static HRESULT ExecuteBundle(
__in BOOTSTRAPPER_RELATION_TYPE relationType,
__in BURN_PACKAGE* pPackage,
__in BOOL fPseudoPackage,
__in BOOL fPerMachine,
__in_z_opt LPCWSTR wzParent,
__in_z_opt LPCWSTR wzIgnoreDependencies,
__in_z_opt LPCWSTR wzAncestors,
Expand Down Expand Up @@ -987,6 +995,16 @@ static HRESULT ExecuteBundle(
hr = CoreAppendFileHandleSelfToCommandLine(sczExecutablePath, &hExecutableFile, &sczBaseCommand, NULL);
ExitOnFailure(hr, "Failed to append %ls", BURN_COMMANDLINE_SWITCH_FILEHANDLE_SELF);

// Configurable-scope bundle packages get the scope of the parent bundle.
// Note that the command-line switch takes effect only if the BA does a
// default plan.
if (BOOTSTRAPPER_PACKAGE_SCOPE_PER_MACHINE_OR_PER_USER == pPackage->scope
|| BOOTSTRAPPER_PACKAGE_SCOPE_PER_USER_OR_PER_MACHINE == pPackage->scope)
{
hr = StrAllocConcat(&sczBaseCommand, fPerMachine ? L" -permachine" : L" -peruser", 0);
ExitOnFailure(hr, "Failed to append scope switch to the command line.");
}

// build user args
if (sczUnformattedUserArgs && *sczUnformattedUserArgs)
{
Expand Down
2 changes: 2 additions & 0 deletions src/burn/engine/bundlepackageengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ HRESULT BundlePackageEngineExecutePackage(
__in BURN_VARIABLES* pVariables,
__in BOOL fRollback,
__in BOOL fCacheAvailable,
__in BOOL fPerMachine,
__in PFN_GENERICMESSAGEHANDLER pfnGenericMessageHandler,
__in LPVOID pvContext,
__out BOOTSTRAPPER_APPLY_RESTART* pRestart
Expand All @@ -63,6 +64,7 @@ HRESULT BundlePackageEngineExecuteRelatedBundle(
__in BURN_CACHE* pCache,
__in BURN_VARIABLES* pVariables,
__in BOOL fRollback,
__in BOOL fPerMachine,
__in PFN_GENERICMESSAGEHANDLER pfnGenericExecuteProgress,
__in LPVOID pvContext,
__out BOOTSTRAPPER_APPLY_RESTART* pRestart
Expand Down
4 changes: 2 additions & 2 deletions src/burn/engine/elevation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2913,7 +2913,7 @@ static HRESULT OnExecuteRelatedBundle(
}

// Execute related bundle.
hr = BundlePackageEngineExecuteRelatedBundle(&executeAction, pCache, pVariables, static_cast<BOOL>(dwRollback), GenericExecuteMessageHandler, hPipe, pRestart);
hr = BundlePackageEngineExecuteRelatedBundle(&executeAction, pCache, pVariables, static_cast<BOOL>(dwRollback), TRUE/*fPerMachine*/, GenericExecuteMessageHandler, hPipe, pRestart);
ExitOnFailure(hr, "Failed to execute related bundle.");

LExit:
Expand Down Expand Up @@ -3008,7 +3008,7 @@ static HRESULT OnExecuteBundlePackage(
}

// Execute BUNDLE package.
hr = BundlePackageEngineExecutePackage(&executeAction, pCache, pVariables, fRollback, fCacheAvailable, GenericExecuteMessageHandler, hPipe, pRestart);
hr = BundlePackageEngineExecutePackage(&executeAction, pCache, pVariables, fRollback, fCacheAvailable, TRUE/*fPerMachine*/, GenericExecuteMessageHandler, hPipe, pRestart);
ExitOnFailure(hr, "Failed to execute BUNDLE package.");

LExit:
Expand Down
2 changes: 1 addition & 1 deletion src/test/burn/TestBA/TestBA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private void ShutdownUiThread(int? exitCode = null)

protected override void OnDetectBegin(DetectBeginEventArgs args)
{
this.Log("OnDetectBegin");
this.Log($"OnDetectBegin: Cached={args.Cached}, RegistrationType={args.RegistrationType}, PackageCount={args.PackageCount}");

this.forceUpdateSource = this.ReadPackageAction(null, "ForceUpdateSource");
if (!String.IsNullOrEmpty(this.forceUpdateSource))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<Project Sdk="WixToolset.Sdk">
<Project>
<PropertyGroup>
<OutputType>Bundle</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="WixToolset.BootstrapperApplications.wixext" />
<PackageReference Include="WixToolset.NetFx.wixext" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\TestBA\TestBAWixlib\testbawixlib.wixproj" />
<ProjectReference Include="..\AllPuomBundle\AllPuomBundleTestBA.wixproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal">
<Bundle Id="AllPuomBundle" Name="AllPuomBundle" Manufacturer="Acme" Version="1.0.0.0">
<Bundle Id="PuomBundlePackage$(BA)" Name="PuomBundlePackage$(BA)" Manufacturer="Acme" Version="1.0.0.0">
<?if $(BA) = "WixStdBA"?>
<BootstrapperApplication>
<bal:WixStandardBootstrapperApplication LicenseUrl="https://www.example.com/license" Theme="hyperlinkLicense" />
</BootstrapperApplication>
<?endif?>

<Variable Name="TestGroupName" Value="ConfigurableScopeTests" />

<Chain>
<BundlePackage SourceFile="AllPuomBundleTestBA.exe" />
<?if $(BA) = "TestBA"?>
<PackageGroupRef Id="TestBA" />
<?endif?>
<BundlePackage SourceFile="AllPuomBundle$(BA).exe" />
</Chain>
</Bundle>
</Wix>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project Sdk="WixToolset.Sdk">
<PropertyGroup>
<BA>TestBA</BA>
</PropertyGroup>

<Import Project="Bundle.props" />
</Project>
34 changes: 34 additions & 0 deletions src/test/burn/WixToolsetTest.BurnE2E/ConfigurableScopeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,40 @@ public void PM_PU_PUOM_Bundle_PU_Plan_Installs_PerUserMostly()
pkg2.VerifyInstalled(false);
}

[RuntimeFact]
public void ConfigurableScopeBundlePackage_Follows_PerUser_Scope()
{
var testBAController = this.CreateTestBAController();
testBAController.SetBundleScope(BundleScope.PerUser);

var bundle = this.CreateBundleInstaller("PuomBundlePackageTestBA");
var log = bundle.Install();

bundle.VerifyRegisteredAndInPackageCache(plannedPerMachine: false);

Assert.True(LogVerifier.MessageInLogFile(log, "Plan begin, 2 packages, action: Install, planned scope: PerUser"));
Assert.True(LogVerifier.MessageInLogFile(log, "Planned package: AllPuomBundleTestBA.exe, state: Absent, default requested: Present, ba requested: Present, execute: Install, rollback: Uninstall, scope: PerUser"));

bundle.Uninstall();
bundle.VerifyUnregisteredAndRemovedFromPackageCache(plannedPerMachine: false);
}

[RuntimeFact]
public void ConfigurableScopeBundlePackage_Follows_PerMachine_Scope()
{
var testBAController = this.CreateTestBAController();
testBAController.SetBundleScope(BundleScope.PerMachine);

var bundle = this.CreateBundleInstaller("PuomBundlePackageTestBA");
var log = bundle.Install();

bundle.VerifyRegisteredAndInPackageCache(plannedPerMachine: true);

Assert.True(LogVerifier.MessageInLogFile(log, "Plan begin, 2 packages, action: Install, planned scope: PerMachine"));
Assert.True(LogVerifier.MessageInLogFile(log, "Planned package: AllPuomBundleTestBA.exe, state: Absent, default requested: Present, ba requested: Present, execute: Install, rollback: Uninstall, scope: PerMachine"));

bundle.Uninstall();
bundle.VerifyUnregisteredAndRemovedFromPackageCache(plannedPerMachine: true);
}
}
}