diff options
| author | Jacob Hoover <jacob.hoover@greenheck.com> | 2022-11-10 10:48:23 -0600 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2022-11-10 23:49:10 -0600 |
| commit | fa393914f12f6d6bc88a73e4d5b009da765f6dd5 (patch) | |
| tree | 6dbf354d4542b3e085795b0a917eaafc1eead415 /src/test | |
| parent | c843b47d6233153fa961c6d0e61edf7cedf255bb (diff) | |
| download | wix-fa393914f12f6d6bc88a73e4d5b009da765f6dd5.tar.gz wix-fa393914f12f6d6bc88a73e4d5b009da765f6dd5.tar.bz2 wix-fa393914f12f6d6bc88a73e4d5b009da765f6dd5.zip | |
WIXFEAT-3704 - Allow access to persisted variables from related bundles
Diffstat (limited to 'src/test')
8 files changed, 345 insertions, 0 deletions
diff --git a/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.cpp b/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.cpp new file mode 100644 index 00000000..5da7b170 --- /dev/null +++ b/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.cpp | |||
| @@ -0,0 +1,133 @@ | |||
| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 2 | |||
| 3 | #include "precomp.h" | ||
| 4 | #include "BalBaseBAFunctions.h" | ||
| 5 | #include "BalBaseBAFunctionsProc.h" | ||
| 6 | |||
| 7 | const DWORD VARIABLE_GROW_FACTOR = 80; | ||
| 8 | const LPCWSTR STRING_VARIABLE = L"AString"; | ||
| 9 | const LPCWSTR NUMBER_VARIABLE = L"ANumber"; | ||
| 10 | |||
| 11 | static void CALLBACK BafRelatedBundleVariableTestingTraceError( | ||
| 12 | __in_z LPCSTR szFile, | ||
| 13 | __in int iLine, | ||
| 14 | __in REPORT_LEVEL rl, | ||
| 15 | __in UINT source, | ||
| 16 | __in HRESULT hrError, | ||
| 17 | __in_z __format_string LPCSTR szFormat, | ||
| 18 | __in va_list args | ||
| 19 | ); | ||
| 20 | |||
| 21 | class CBafRelatedBundleVariableTesting : public CBalBaseBAFunctions | ||
| 22 | { | ||
| 23 | public: // IBAFunctions | ||
| 24 | |||
| 25 | |||
| 26 | public: //IBootstrapperApplication | ||
| 27 | virtual STDMETHODIMP OnDetectRelatedBundle( | ||
| 28 | __in_z LPCWSTR wzBundleId, | ||
| 29 | __in BOOTSTRAPPER_RELATION_TYPE relationType, | ||
| 30 | __in_z LPCWSTR wzBundleTag, | ||
| 31 | __in BOOL fPerMachine, | ||
| 32 | __in LPCWSTR wzVersion, | ||
| 33 | __in BOOL fMissingFromCache, | ||
| 34 | __inout BOOL* pfCancel | ||
| 35 | ) | ||
| 36 | { | ||
| 37 | |||
| 38 | HRESULT hr = S_OK; | ||
| 39 | LPWSTR wzValue = NULL; | ||
| 40 | |||
| 41 | hr = BalGetRelatedBundleVariable(wzBundleId, STRING_VARIABLE, &wzValue); | ||
| 42 | |||
| 43 | ExitOnFailure(hr, "Failed to get related bundle string variable."); | ||
| 44 | |||
| 45 | if (wzValue) | ||
| 46 | { | ||
| 47 | BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "AString = %ws", wzValue); | ||
| 48 | } | ||
| 49 | |||
| 50 | hr = BalGetRelatedBundleVariable(wzBundleId, NUMBER_VARIABLE, &wzValue); | ||
| 51 | |||
| 52 | if (wzValue) | ||
| 53 | { | ||
| 54 | BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "ANumber = %ws", wzValue); | ||
| 55 | } | ||
| 56 | |||
| 57 | hr = __super::OnDetectRelatedBundle(wzBundleId, relationType, wzBundleTag, fPerMachine, wzVersion, fMissingFromCache, pfCancel); | ||
| 58 | LExit: | ||
| 59 | ReleaseStr(wzValue); | ||
| 60 | return hr; | ||
| 61 | } | ||
| 62 | private: | ||
| 63 | |||
| 64 | |||
| 65 | public: | ||
| 66 | // | ||
| 67 | // Constructor - initialize member variables. | ||
| 68 | // | ||
| 69 | CBafRelatedBundleVariableTesting( | ||
| 70 | __in HMODULE hModule, | ||
| 71 | __in IBootstrapperEngine* pEngine, | ||
| 72 | __in const BA_FUNCTIONS_CREATE_ARGS* pArgs | ||
| 73 | ) : CBalBaseBAFunctions(hModule, pEngine, pArgs) | ||
| 74 | { | ||
| 75 | } | ||
| 76 | |||
| 77 | // | ||
| 78 | // Destructor - release member variables. | ||
| 79 | // | ||
| 80 | ~CBafRelatedBundleVariableTesting() | ||
| 81 | { | ||
| 82 | } | ||
| 83 | |||
| 84 | private: | ||
| 85 | }; | ||
| 86 | |||
| 87 | |||
| 88 | HRESULT WINAPI CreateBAFunctions( | ||
| 89 | __in HMODULE hModule, | ||
| 90 | __in const BA_FUNCTIONS_CREATE_ARGS* pArgs, | ||
| 91 | __inout BA_FUNCTIONS_CREATE_RESULTS* pResults | ||
| 92 | ) | ||
| 93 | { | ||
| 94 | HRESULT hr = S_OK; | ||
| 95 | CBafRelatedBundleVariableTesting* pBAFunctions = NULL; | ||
| 96 | IBootstrapperEngine* pEngine = NULL; | ||
| 97 | |||
| 98 | DutilInitialize(&BafRelatedBundleVariableTestingTraceError); | ||
| 99 | |||
| 100 | hr = BalInitializeFromCreateArgs(pArgs->pBootstrapperCreateArgs, &pEngine); | ||
| 101 | ExitOnFailure(hr, "Failed to initialize Bal."); | ||
| 102 | |||
| 103 | pBAFunctions = new CBafRelatedBundleVariableTesting(hModule, pEngine, pArgs); | ||
| 104 | ExitOnNull(pBAFunctions, hr, E_OUTOFMEMORY, "Failed to create new CBafRelatedBundleVariableTesting object."); | ||
| 105 | |||
| 106 | pResults->pfnBAFunctionsProc = BalBaseBAFunctionsProc; | ||
| 107 | pResults->pvBAFunctionsProcContext = pBAFunctions; | ||
| 108 | pBAFunctions = NULL; | ||
| 109 | |||
| 110 | LExit: | ||
| 111 | ReleaseObject(pBAFunctions); | ||
| 112 | ReleaseObject(pEngine); | ||
| 113 | |||
| 114 | return hr; | ||
| 115 | } | ||
| 116 | |||
| 117 | static void CALLBACK BafRelatedBundleVariableTestingTraceError( | ||
| 118 | __in_z LPCSTR /*szFile*/, | ||
| 119 | __in int /*iLine*/, | ||
| 120 | __in REPORT_LEVEL /*rl*/, | ||
| 121 | __in UINT source, | ||
| 122 | __in HRESULT hrError, | ||
| 123 | __in_z __format_string LPCSTR szFormat, | ||
| 124 | __in va_list args | ||
| 125 | ) | ||
| 126 | { | ||
| 127 | // BalLogError currently uses the Exit... macros, | ||
| 128 | // so if expanding the scope need to ensure this doesn't get called recursively. | ||
| 129 | if (DUTIL_SOURCE_THMUTIL == source) | ||
| 130 | { | ||
| 131 | BalLogErrorArgs(hrError, szFormat, args); | ||
| 132 | } | ||
| 133 | } | ||
diff --git a/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.def b/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.def new file mode 100644 index 00000000..6e016dad --- /dev/null +++ b/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.def | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | ; Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 2 | |||
| 3 | |||
| 4 | EXPORTS | ||
| 5 | BAFunctionsCreate | ||
| 6 | BAFunctionsDestroy | ||
diff --git a/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.vcxproj b/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.vcxproj new file mode 100644 index 00000000..94d44ac3 --- /dev/null +++ b/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/BafRelatedBundleVariableTesting.vcxproj | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. --> | ||
| 3 | |||
| 4 | <Project DefaultTargets="Build" Toolsxmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| 5 | <ItemGroup Label="ProjectConfigurations"> | ||
| 6 | <ProjectConfiguration Include="Debug|ARM64"> | ||
| 7 | <Configuration>Debug</Configuration> | ||
| 8 | <Platform>ARM64</Platform> | ||
| 9 | </ProjectConfiguration> | ||
| 10 | <ProjectConfiguration Include="Release|ARM64"> | ||
| 11 | <Configuration>Release</Configuration> | ||
| 12 | <Platform>ARM64</Platform> | ||
| 13 | </ProjectConfiguration> | ||
| 14 | <ProjectConfiguration Include="Debug|Win32"> | ||
| 15 | <Configuration>Debug</Configuration> | ||
| 16 | <Platform>Win32</Platform> | ||
| 17 | </ProjectConfiguration> | ||
| 18 | <ProjectConfiguration Include="Release|Win32"> | ||
| 19 | <Configuration>Release</Configuration> | ||
| 20 | <Platform>Win32</Platform> | ||
| 21 | </ProjectConfiguration> | ||
| 22 | <ProjectConfiguration Include="Debug|x64"> | ||
| 23 | <Configuration>Debug</Configuration> | ||
| 24 | <Platform>x64</Platform> | ||
| 25 | </ProjectConfiguration> | ||
| 26 | <ProjectConfiguration Include="Release|x64"> | ||
| 27 | <Configuration>Release</Configuration> | ||
| 28 | <Platform>x64</Platform> | ||
| 29 | </ProjectConfiguration> | ||
| 30 | </ItemGroup> | ||
| 31 | |||
| 32 | <PropertyGroup Label="Globals"> | ||
| 33 | <ProjectGuid>{DDD02BDE-B44F-4F37-A359-CE802750CB45}</ProjectGuid> | ||
| 34 | <ConfigurationType>DynamicLibrary</ConfigurationType> | ||
| 35 | <CharacterSet>Unicode</CharacterSet> | ||
| 36 | <TargetName>BafRelatedBundleVariableTesting</TargetName> | ||
| 37 | <ProjectModuleDefinitionFile>BafRelatedBundleVariableTesting.def</ProjectModuleDefinitionFile> | ||
| 38 | <IsWixTestProject>true</IsWixTestProject> | ||
| 39 | </PropertyGroup> | ||
| 40 | |||
| 41 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
| 42 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
| 43 | |||
| 44 | <PropertyGroup> | ||
| 45 | <ProjectAdditionalLinkLibraries>comctl32.lib;gdiplus.lib;msimg32.lib;shlwapi.lib;wininet.lib</ProjectAdditionalLinkLibraries> | ||
| 46 | </PropertyGroup> | ||
| 47 | |||
| 48 | <ItemGroup> | ||
| 49 | <ClCompile Include="BafRelatedBundleVariableTesting.cpp" /> | ||
| 50 | <ClCompile Include="precomp.cpp"> | ||
| 51 | <PrecompiledHeader>Create</PrecompiledHeader> | ||
| 52 | </ClCompile> | ||
| 53 | </ItemGroup> | ||
| 54 | <ItemGroup> | ||
| 55 | <ClInclude Include="precomp.h" /> | ||
| 56 | </ItemGroup> | ||
| 57 | <ItemGroup> | ||
| 58 | <None Include="BafRelatedBundleVariableTesting.def" /> | ||
| 59 | </ItemGroup> | ||
| 60 | |||
| 61 | <ItemGroup> | ||
| 62 | <PackageReference Include="WixToolset.BalUtil" /> | ||
| 63 | </ItemGroup> | ||
| 64 | |||
| 65 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
| 66 | </Project> | ||
diff --git a/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/precomp.cpp b/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/precomp.cpp new file mode 100644 index 00000000..fc9d1177 --- /dev/null +++ b/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/precomp.cpp | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 2 | |||
| 3 | #include "precomp.h" | ||
| 4 | |||
| 5 | static HINSTANCE vhInstance = NULL; | ||
| 6 | |||
| 7 | extern "C" BOOL WINAPI DllMain( | ||
| 8 | IN HINSTANCE hInstance, | ||
| 9 | IN DWORD dwReason, | ||
| 10 | IN LPVOID /* pvReserved */ | ||
| 11 | ) | ||
| 12 | { | ||
| 13 | switch (dwReason) | ||
| 14 | { | ||
| 15 | case DLL_PROCESS_ATTACH: | ||
| 16 | ::DisableThreadLibraryCalls(hInstance); | ||
| 17 | vhInstance = hInstance; | ||
| 18 | break; | ||
| 19 | |||
| 20 | case DLL_PROCESS_DETACH: | ||
| 21 | vhInstance = NULL; | ||
| 22 | break; | ||
| 23 | } | ||
| 24 | |||
| 25 | return TRUE; | ||
| 26 | } | ||
| 27 | |||
| 28 | extern "C" HRESULT WINAPI BAFunctionsCreate( | ||
| 29 | __in const BA_FUNCTIONS_CREATE_ARGS* pArgs, | ||
| 30 | __inout BA_FUNCTIONS_CREATE_RESULTS* pResults | ||
| 31 | ) | ||
| 32 | { | ||
| 33 | HRESULT hr = S_OK; | ||
| 34 | |||
| 35 | hr = CreateBAFunctions(vhInstance, pArgs, pResults); | ||
| 36 | BalExitOnFailure(hr, "Failed to create BAFunctions interface."); | ||
| 37 | |||
| 38 | LExit: | ||
| 39 | return hr; | ||
| 40 | } | ||
| 41 | |||
| 42 | extern "C" void WINAPI BAFunctionsDestroy( | ||
| 43 | __in const BA_FUNCTIONS_DESTROY_ARGS* /*pArgs*/, | ||
| 44 | __inout BA_FUNCTIONS_DESTROY_RESULTS* /*pResults*/ | ||
| 45 | ) | ||
| 46 | { | ||
| 47 | BalUninitialize(); | ||
| 48 | } | ||
diff --git a/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/precomp.h b/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/precomp.h new file mode 100644 index 00000000..2e14786a --- /dev/null +++ b/src/test/burn/TestData/Manual/BafRelatedBundleVariableTesting/precomp.h | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | #pragma once | ||
| 2 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 3 | |||
| 4 | |||
| 5 | #include <windows.h> | ||
| 6 | |||
| 7 | #pragma warning(push) | ||
| 8 | #pragma warning(disable:4458) // declaration of 'xxx' hides class member | ||
| 9 | #include <gdiplus.h> | ||
| 10 | #pragma warning(pop) | ||
| 11 | |||
| 12 | #include <msiquery.h> | ||
| 13 | #include <objbase.h> | ||
| 14 | #include <shlobj.h> | ||
| 15 | #include <shlwapi.h> | ||
| 16 | #include <stdlib.h> | ||
| 17 | #include <strsafe.h> | ||
| 18 | #include <CommCtrl.h> | ||
| 19 | #include <sddl.h> | ||
| 20 | |||
| 21 | #include "dutil.h" | ||
| 22 | #include "dictutil.h" | ||
| 23 | #include "fileutil.h" | ||
| 24 | #include "locutil.h" | ||
| 25 | #include "memutil.h" | ||
| 26 | #include "pathutil.h" | ||
| 27 | #include "procutil.h" | ||
| 28 | #include "strutil.h" | ||
| 29 | #include "thmutil.h" | ||
| 30 | #include "regutil.h" | ||
| 31 | #include "xmlutil.h" | ||
| 32 | |||
| 33 | #include "BalBaseBootstrapperApplication.h" | ||
| 34 | #include "balutil.h" | ||
| 35 | |||
| 36 | #include "BAFunctions.h" | ||
| 37 | #include "IBAFunctions.h" | ||
| 38 | |||
| 39 | HRESULT WINAPI CreateBAFunctions( | ||
| 40 | __in HMODULE hModule, | ||
| 41 | __in const BA_FUNCTIONS_CREATE_ARGS* pArgs, | ||
| 42 | __inout BA_FUNCTIONS_CREATE_RESULTS* pResults | ||
| 43 | ); | ||
diff --git a/src/test/burn/TestData/Manual/BundleD/BundleD.wixproj b/src/test/burn/TestData/Manual/BundleD/BundleD.wixproj new file mode 100644 index 00000000..1df1f895 --- /dev/null +++ b/src/test/burn/TestData/Manual/BundleD/BundleD.wixproj | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | <!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. --> | ||
| 2 | <Project Sdk="WixToolset.Sdk"> | ||
| 3 | <PropertyGroup> | ||
| 4 | <OutputType>Bundle</OutputType> | ||
| 5 | <BA>customHyperlinkLicense</BA> | ||
| 6 | <UpgradeCode>{98ACBCF6-B54A-46AF-8990-DFB8795B965B}</UpgradeCode> | ||
| 7 | <Version Condition=" '$(Version)' == '' ">1.0.0.0</Version> | ||
| 8 | </PropertyGroup> | ||
| 9 | <ItemGroup> | ||
| 10 | <Compile Include="..\..\Templates\Bundle.wxs" Link="Bundle.wxs" /> | ||
| 11 | </ItemGroup> | ||
| 12 | <ItemGroup> | ||
| 13 | <ProjectReference Include="..\BafRelatedBundleVariableTesting\BafRelatedBundleVariableTesting.vcxproj" Properties="Platform=x86" ReferenceOutputAssembly="false" /> | ||
| 14 | <ProjectReference Include="..\PackageA\PackageA.wixproj" /> | ||
| 15 | </ItemGroup> | ||
| 16 | <ItemGroup> | ||
| 17 | <PackageReference Include="WixToolset.Bal.wixext" /> | ||
| 18 | </ItemGroup> | ||
| 19 | <Target Name="CopyManualInstructions" AfterTargets="AfterBuild"> | ||
| 20 | <Copy SourceFiles="ManualTests.txt" DestinationFiles="$(OutputPath)ManualTests.txt" /> | ||
| 21 | </Target> | ||
| 22 | </Project> | ||
diff --git a/src/test/burn/TestData/Manual/BundleD/BundleD.wxs b/src/test/burn/TestData/Manual/BundleD/BundleD.wxs new file mode 100644 index 00000000..a877e214 --- /dev/null +++ b/src/test/burn/TestData/Manual/BundleD/BundleD.wxs | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | <!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. --> | ||
| 2 | |||
| 3 | |||
| 4 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal"> | ||
| 5 | <Fragment> | ||
| 6 | <BootstrapperApplication Id="customHyperlinkLicense"> | ||
| 7 | <!-- WixStandardBootstrapperApplication.RtfLicense --> | ||
| 8 | <bal:WixStandardBootstrapperApplication LicenseUrl="" Theme="hyperlinkLicense" /> | ||
| 9 | <Payload SourceFile="$(var.BafRelatedBundleVariableTesting.TargetPath)" bal:BAFunctions="yes" /> | ||
| 10 | </BootstrapperApplication> | ||
| 11 | <PackageGroup Id="BundlePackages"> | ||
| 12 | <MsiPackage Id="PackageA" SourceFile="$(var.PackageA.TargetPath)" /> | ||
| 13 | </PackageGroup> | ||
| 14 | <Variable Name="ANumber" bal:Overridable="yes" Value="42" Persisted="yes" /> | ||
| 15 | <Variable Name="AString" bal:Overridable="yes" Value="This is a test" Persisted="yes" /> | ||
| 16 | </Fragment> | ||
| 17 | </Wix> | ||
diff --git a/src/test/burn/TestData/Manual/BundleD/ManualTests.txt b/src/test/burn/TestData/Manual/BundleD/ManualTests.txt new file mode 100644 index 00000000..309338cc --- /dev/null +++ b/src/test/burn/TestData/Manual/BundleD/ManualTests.txt | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | BafRelatedBundleVariableTesting | ||
| 2 | # Building, Run initial build w/ no parameters, run a second (re)build w/ a /p:Version=1.1.0.0 (ensure it actually builds, as CLI params aren't accounted in the build optimization) | ||
| 3 | 1. Run BundleD.exe (v1.0). | ||
| 4 | 2. Click Install. | ||
| 5 | 3. Verify that the Bundle installs successfully. | ||
| 6 | 4. Run BundleD.exe (v1.1). | ||
| 7 | 5. Check the log file in %TEMP% There should be lines reporting: | ||
| 8 | [0708:04B4]i000: AString = This is a test | ||
| 9 | [0708:04B4]i000: ANumber = 42 | ||
| 10 | |||
