From d5985a1688bc878e42ffd3ce3939fa52303cab16 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 13 May 2022 15:39:40 -0500 Subject: Add option to hosts to always install prereqs. Add PrereqPackage to BundlePackage Implements 4718 --- src/test/burn/TestBA/TestBA.cs | 7 + .../TestData/PrereqBaTests/BundleA/BundleA.wixproj | 5 +- .../TestData/PrereqBaTests/BundleA/BundleA.wxs | 12 +- .../TestData/PrereqBaTests/BundleB/BundleB.wixproj | 5 +- .../TestData/PrereqBaTests/BundleB/BundleB.wxs | 12 +- .../TestData/PrereqBaTests/BundleC/BundleC.wixproj | 24 +++ .../TestData/PrereqBaTests/BundleC/BundleC.wxs | 30 +++ .../PrereqBaTests/BundleC/bad.runtimeconfig.json | 10 + .../TestData/PrereqBaTests/BundleD/BundleD.wixproj | 24 +++ .../TestData/PrereqBaTests/BundleD/BundleD.wxs | 29 +++ .../burn/TestData/PrereqBaTests/BundleD/bad.config | 17 ++ .../TestData/PrereqBaTests/BundleE/BundleE.wixproj | 22 ++ .../TestData/PrereqBaTests/BundleE/BundleE.wxs | 26 +++ .../PrereqBaTests/PackageC/PackageC.wixproj | 9 + .../PrereqBaTests/PackageF/PackageF.wixproj | 12 -- .../TestData/PrereqBaTests/PrereqBaf/PrereqBaf.cpp | 79 ++++++++ .../TestData/PrereqBaTests/PrereqBaf/PrereqBaf.def | 6 + .../PrereqBaTests/PrereqBaf/PrereqBaf.vcxproj | 66 ++++++ .../TestData/PrereqBaTests/PrereqBaf/precomp.cpp | 48 +++++ .../TestData/PrereqBaTests/PrereqBaf/precomp.h | 31 +++ .../PrereqBaTests/ReplaceConfig/ReplaceConfig.cpp | 33 +++ .../ReplaceConfig/ReplaceConfig.vcxproj | 63 ++++++ .../PrereqBaTests/ReplaceConfig/precomp.cpp | 3 + .../TestData/PrereqBaTests/ReplaceConfig/precomp.h | 17 ++ src/test/burn/WixTestTools/BundleInstaller.cs | 14 ++ .../burn/WixToolsetTest.BurnE2E/PrereqBaTests.cs | 225 ++++++++++++++++++++- 26 files changed, 807 insertions(+), 22 deletions(-) create mode 100644 src/test/burn/TestData/PrereqBaTests/BundleC/BundleC.wixproj create mode 100644 src/test/burn/TestData/PrereqBaTests/BundleC/BundleC.wxs create mode 100644 src/test/burn/TestData/PrereqBaTests/BundleC/bad.runtimeconfig.json create mode 100644 src/test/burn/TestData/PrereqBaTests/BundleD/BundleD.wixproj create mode 100644 src/test/burn/TestData/PrereqBaTests/BundleD/BundleD.wxs create mode 100644 src/test/burn/TestData/PrereqBaTests/BundleD/bad.config create mode 100644 src/test/burn/TestData/PrereqBaTests/BundleE/BundleE.wixproj create mode 100644 src/test/burn/TestData/PrereqBaTests/BundleE/BundleE.wxs create mode 100644 src/test/burn/TestData/PrereqBaTests/PackageC/PackageC.wixproj delete mode 100644 src/test/burn/TestData/PrereqBaTests/PackageF/PackageF.wixproj create mode 100644 src/test/burn/TestData/PrereqBaTests/PrereqBaf/PrereqBaf.cpp create mode 100644 src/test/burn/TestData/PrereqBaTests/PrereqBaf/PrereqBaf.def create mode 100644 src/test/burn/TestData/PrereqBaTests/PrereqBaf/PrereqBaf.vcxproj create mode 100644 src/test/burn/TestData/PrereqBaTests/PrereqBaf/precomp.cpp create mode 100644 src/test/burn/TestData/PrereqBaTests/PrereqBaf/precomp.h create mode 100644 src/test/burn/TestData/PrereqBaTests/ReplaceConfig/ReplaceConfig.cpp create mode 100644 src/test/burn/TestData/PrereqBaTests/ReplaceConfig/ReplaceConfig.vcxproj create mode 100644 src/test/burn/TestData/PrereqBaTests/ReplaceConfig/precomp.cpp create mode 100644 src/test/burn/TestData/PrereqBaTests/ReplaceConfig/precomp.h (limited to 'src/test') diff --git a/src/test/burn/TestBA/TestBA.cs b/src/test/burn/TestBA/TestBA.cs index 1548c05b..9ca82377 100644 --- a/src/test/burn/TestBA/TestBA.cs +++ b/src/test/burn/TestBA/TestBA.cs @@ -146,6 +146,13 @@ namespace WixToolset.Test.BA this.wait.WaitOne(); + if (this.action == LaunchAction.Help) + { + this.Log("This is a BA for automated testing"); + this.Engine.Quit(0); + return; + } + this.redetectRemaining = redetectCount; for (int i = -1; i < redetectCount; i++) { diff --git a/src/test/burn/TestData/PrereqBaTests/BundleA/BundleA.wixproj b/src/test/burn/TestData/PrereqBaTests/BundleA/BundleA.wixproj index 0199f91f..b084997c 100644 --- a/src/test/burn/TestData/PrereqBaTests/BundleA/BundleA.wixproj +++ b/src/test/burn/TestData/PrereqBaTests/BundleA/BundleA.wixproj @@ -13,9 +13,12 @@ - + + + + \ No newline at end of file diff --git a/src/test/burn/TestData/PrereqBaTests/BundleA/BundleA.wxs b/src/test/burn/TestData/PrereqBaTests/BundleA/BundleA.wxs index 682f0bd7..6073e09f 100644 --- a/src/test/burn/TestData/PrereqBaTests/BundleA/BundleA.wxs +++ b/src/test/burn/TestData/PrereqBaTests/BundleA/BundleA.wxs @@ -1,22 +1,30 @@  - + + + + + + + - + diff --git a/src/test/burn/TestData/PrereqBaTests/BundleB/BundleB.wixproj b/src/test/burn/TestData/PrereqBaTests/BundleB/BundleB.wixproj index d4288d4b..843b382a 100644 --- a/src/test/burn/TestData/PrereqBaTests/BundleB/BundleB.wixproj +++ b/src/test/burn/TestData/PrereqBaTests/BundleB/BundleB.wixproj @@ -13,9 +13,12 @@ - + + + + \ No newline at end of file diff --git a/src/test/burn/TestData/PrereqBaTests/BundleB/BundleB.wxs b/src/test/burn/TestData/PrereqBaTests/BundleB/BundleB.wxs index 603c3aee..b7742582 100644 --- a/src/test/burn/TestData/PrereqBaTests/BundleB/BundleB.wxs +++ b/src/test/burn/TestData/PrereqBaTests/BundleB/BundleB.wxs @@ -1,21 +1,29 @@  - + + + + + + + - + diff --git a/src/test/burn/TestData/PrereqBaTests/BundleC/BundleC.wixproj b/src/test/burn/TestData/PrereqBaTests/BundleC/BundleC.wixproj new file mode 100644 index 00000000..81641f66 --- /dev/null +++ b/src/test/burn/TestData/PrereqBaTests/BundleC/BundleC.wixproj @@ -0,0 +1,24 @@ + + + + Bundle + BrokenDncAlwaysPrereq + {D2763AB7-979B-485C-AE52-DD03C23CCB93} + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/burn/TestData/PrereqBaTests/BundleC/BundleC.wxs b/src/test/burn/TestData/PrereqBaTests/BundleC/BundleC.wxs new file mode 100644 index 00000000..fe9425f7 --- /dev/null +++ b/src/test/burn/TestData/PrereqBaTests/BundleC/BundleC.wxs @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/burn/TestData/PrereqBaTests/BundleC/bad.runtimeconfig.json b/src/test/burn/TestData/PrereqBaTests/BundleC/bad.runtimeconfig.json new file mode 100644 index 00000000..07a1a830 --- /dev/null +++ b/src/test/burn/TestData/PrereqBaTests/BundleC/bad.runtimeconfig.json @@ -0,0 +1,10 @@ +{ + "runtimeOptions": { + "tfm": "net5.5", + "rollForward": "Disable", + "framework": { + "name": "Microsoft.WindowsDesktop.App", + "version": "5.5.0" + } + } +} \ No newline at end of file diff --git a/src/test/burn/TestData/PrereqBaTests/BundleD/BundleD.wixproj b/src/test/burn/TestData/PrereqBaTests/BundleD/BundleD.wixproj new file mode 100644 index 00000000..314fe2e2 --- /dev/null +++ b/src/test/burn/TestData/PrereqBaTests/BundleD/BundleD.wixproj @@ -0,0 +1,24 @@ + + + + Bundle + BrokenMbaAlwaysPrereq + {415CA128-60E1-4D16-ACE8-A1D43E98B997} + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/burn/TestData/PrereqBaTests/BundleD/BundleD.wxs b/src/test/burn/TestData/PrereqBaTests/BundleD/BundleD.wxs new file mode 100644 index 00000000..0e866295 --- /dev/null +++ b/src/test/burn/TestData/PrereqBaTests/BundleD/BundleD.wxs @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/burn/TestData/PrereqBaTests/BundleD/bad.config b/src/test/burn/TestData/PrereqBaTests/BundleD/bad.config new file mode 100644 index 00000000..1512e59a --- /dev/null +++ b/src/test/burn/TestData/PrereqBaTests/BundleD/bad.config @@ -0,0 +1,17 @@ + + + + + + + +
+ + + + + + + + + diff --git a/src/test/burn/TestData/PrereqBaTests/BundleE/BundleE.wixproj b/src/test/burn/TestData/PrereqBaTests/BundleE/BundleE.wixproj new file mode 100644 index 00000000..5d271f55 --- /dev/null +++ b/src/test/burn/TestData/PrereqBaTests/BundleE/BundleE.wixproj @@ -0,0 +1,22 @@ + + + + Bundle + DncAlwaysPrereq + {2F61ECD8-C28B-4FF9-9609-0E9633716CF9} + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/burn/TestData/PrereqBaTests/BundleE/BundleE.wxs b/src/test/burn/TestData/PrereqBaTests/BundleE/BundleE.wxs new file mode 100644 index 00000000..5f2e6a75 --- /dev/null +++ b/src/test/burn/TestData/PrereqBaTests/BundleE/BundleE.wxs @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/burn/TestData/PrereqBaTests/PackageC/PackageC.wixproj b/src/test/burn/TestData/PrereqBaTests/PackageC/PackageC.wixproj new file mode 100644 index 00000000..1c8c4fa8 --- /dev/null +++ b/src/test/burn/TestData/PrereqBaTests/PackageC/PackageC.wixproj @@ -0,0 +1,9 @@ + + + + {7DEEE928-CD7F-49AD-8000-2ED6339D8A78} + + + + + \ No newline at end of file diff --git a/src/test/burn/TestData/PrereqBaTests/PackageF/PackageF.wixproj b/src/test/burn/TestData/PrereqBaTests/PackageF/PackageF.wixproj deleted file mode 100644 index 00ffb7d8..00000000 --- a/src/test/burn/TestData/PrereqBaTests/PackageF/PackageF.wixproj +++ /dev/null @@ -1,12 +0,0 @@ - - - - {7DEEE928-CD7F-49AD-8000-2ED6339D8A78} - - - - - - - - \ No newline at end of file diff --git a/src/test/burn/TestData/PrereqBaTests/PrereqBaf/PrereqBaf.cpp b/src/test/burn/TestData/PrereqBaTests/PrereqBaf/PrereqBaf.cpp new file mode 100644 index 00000000..35949eb9 --- /dev/null +++ b/src/test/burn/TestData/PrereqBaTests/PrereqBaf/PrereqBaf.cpp @@ -0,0 +1,79 @@ +// 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. + +#include "precomp.h" +#include "BalBaseBAFunctions.h" +#include "BalBaseBAFunctionsProc.h" + +class CPrereqBaf : public CBalBaseBAFunctions +{ +public: // IBAFunctions + +public: //IBootstrapperApplication + + virtual STDMETHODIMP OnDetectBegin( + __in BOOL /*fCached*/, + __in BOOTSTRAPPER_REGISTRATION_TYPE /*registrationType*/, + __in DWORD /*cPackages*/, + __inout BOOL* /*pfCancel*/ + ) + { + HRESULT hr = S_OK; + + hr = m_pEngine->SetVariableString(L"BARuntimeDirectory", m_command.wzBootstrapperWorkingFolder, FALSE); + ExitOnFailure(hr, "Failed to set BARuntimeDirectory"); + + LExit: + return hr; + } + +private: + +public: + // + // Constructor - initialize member variables. + // + CPrereqBaf( + __in HMODULE hModule, + __in IBootstrapperEngine* pEngine, + __in const BA_FUNCTIONS_CREATE_ARGS* pArgs + ) : CBalBaseBAFunctions(hModule, pEngine, pArgs) + { + } + + // + // Destructor - release member variables. + // + ~CPrereqBaf() + { + } + +private: +}; + + +HRESULT WINAPI CreateBAFunctions( + __in HMODULE hModule, + __in const BA_FUNCTIONS_CREATE_ARGS* pArgs, + __inout BA_FUNCTIONS_CREATE_RESULTS* pResults + ) +{ + HRESULT hr = S_OK; + CPrereqBaf* pBAFunctions = NULL; + IBootstrapperEngine* pEngine = NULL; + + hr = BalInitializeFromCreateArgs(pArgs->pBootstrapperCreateArgs, &pEngine); + ExitOnFailure(hr, "Failed to initialize Bal."); + + pBAFunctions = new CPrereqBaf(hModule, pEngine, pArgs); + ExitOnNull(pBAFunctions, hr, E_OUTOFMEMORY, "Failed to create new CPrereqBaf object."); + + pResults->pfnBAFunctionsProc = BalBaseBAFunctionsProc; + pResults->pvBAFunctionsProcContext = pBAFunctions; + pBAFunctions = NULL; + +LExit: + ReleaseObject(pBAFunctions); + ReleaseObject(pEngine); + + return hr; +} diff --git a/src/test/burn/TestData/PrereqBaTests/PrereqBaf/PrereqBaf.def b/src/test/burn/TestData/PrereqBaTests/PrereqBaf/PrereqBaf.def new file mode 100644 index 00000000..6e016dad --- /dev/null +++ b/src/test/burn/TestData/PrereqBaTests/PrereqBaf/PrereqBaf.def @@ -0,0 +1,6 @@ +; 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. + + +EXPORTS + BAFunctionsCreate + BAFunctionsDestroy diff --git a/src/test/burn/TestData/PrereqBaTests/PrereqBaf/PrereqBaf.vcxproj b/src/test/burn/TestData/PrereqBaTests/PrereqBaf/PrereqBaf.vcxproj new file mode 100644 index 00000000..0d8d63be --- /dev/null +++ b/src/test/burn/TestData/PrereqBaTests/PrereqBaf/PrereqBaf.vcxproj @@ -0,0 +1,66 @@ + + + + + + + Debug + ARM64 + + + Release + ARM64 + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + {C0A11DDB-6CCE-44EC-88FD-93910C2916E3} + DynamicLibrary + Unicode + PrereqBaf + PrereqBaf.def + true + + + + + + + comctl32.lib;gdiplus.lib;msimg32.lib;shlwapi.lib;wininet.lib + + + + + Create + + + + + + + + + + + + + + + + diff --git a/src/test/burn/TestData/PrereqBaTests/PrereqBaf/precomp.cpp b/src/test/burn/TestData/PrereqBaTests/PrereqBaf/precomp.cpp new file mode 100644 index 00000000..fc9d1177 --- /dev/null +++ b/src/test/burn/TestData/PrereqBaTests/PrereqBaf/precomp.cpp @@ -0,0 +1,48 @@ +// 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. + +#include "precomp.h" + +static HINSTANCE vhInstance = NULL; + +extern "C" BOOL WINAPI DllMain( + IN HINSTANCE hInstance, + IN DWORD dwReason, + IN LPVOID /* pvReserved */ + ) +{ + switch (dwReason) + { + case DLL_PROCESS_ATTACH: + ::DisableThreadLibraryCalls(hInstance); + vhInstance = hInstance; + break; + + case DLL_PROCESS_DETACH: + vhInstance = NULL; + break; + } + + return TRUE; +} + +extern "C" HRESULT WINAPI BAFunctionsCreate( + __in const BA_FUNCTIONS_CREATE_ARGS* pArgs, + __inout BA_FUNCTIONS_CREATE_RESULTS* pResults + ) +{ + HRESULT hr = S_OK; + + hr = CreateBAFunctions(vhInstance, pArgs, pResults); + BalExitOnFailure(hr, "Failed to create BAFunctions interface."); + +LExit: + return hr; +} + +extern "C" void WINAPI BAFunctionsDestroy( + __in const BA_FUNCTIONS_DESTROY_ARGS* /*pArgs*/, + __inout BA_FUNCTIONS_DESTROY_RESULTS* /*pResults*/ + ) +{ + BalUninitialize(); +} diff --git a/src/test/burn/TestData/PrereqBaTests/PrereqBaf/precomp.h b/src/test/burn/TestData/PrereqBaTests/PrereqBaf/precomp.h new file mode 100644 index 00000000..8320bdd8 --- /dev/null +++ b/src/test/burn/TestData/PrereqBaTests/PrereqBaf/precomp.h @@ -0,0 +1,31 @@ +#pragma once +// 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. + + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "dutil.h" +#include "dictutil.h" +#include "fileutil.h" +#include "locutil.h" +#include "pathutil.h" +#include "strutil.h" + +#include "BalBaseBootstrapperApplication.h" +#include "balutil.h" + +#include "BAFunctions.h" +#include "IBAFunctions.h" + +HRESULT WINAPI CreateBAFunctions( + __in HMODULE hModule, + __in const BA_FUNCTIONS_CREATE_ARGS* pArgs, + __inout BA_FUNCTIONS_CREATE_RESULTS* pResults + ); diff --git a/src/test/burn/TestData/PrereqBaTests/ReplaceConfig/ReplaceConfig.cpp b/src/test/burn/TestData/PrereqBaTests/ReplaceConfig/ReplaceConfig.cpp new file mode 100644 index 00000000..1fa71bc2 --- /dev/null +++ b/src/test/burn/TestData/PrereqBaTests/ReplaceConfig/ReplaceConfig.cpp @@ -0,0 +1,33 @@ +// 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. + +#include "precomp.h" + +int __cdecl wmain( + __in int argc, + __in LPWSTR argv[] + ) +{ + HRESULT hr = S_OK; + DWORD dwExitCode = 0; + LPCWSTR wzDestinationFile = argc > 1 ? argv[1] : NULL; + LPCWSTR wzGoodFile = argc > 2 ? argv[2] : NULL; + LPCWSTR wzBadFile = argc > 3 ? argv[3] : NULL; + + if (argc != 4) + { + ExitWithRootFailure(hr, E_INVALIDARG, "Invalid args"); + } + + if (!::MoveFileW(wzDestinationFile, wzBadFile)) + { + ExitWithLastError(hr, "Failed to move bad file"); + } + + if (!::MoveFileW(wzGoodFile, wzDestinationFile)) + { + ExitWithLastError(hr, "Failed to move good file"); + } + +LExit: + return FAILED(hr) ? (int)hr : (int)dwExitCode; +} diff --git a/src/test/burn/TestData/PrereqBaTests/ReplaceConfig/ReplaceConfig.vcxproj b/src/test/burn/TestData/PrereqBaTests/ReplaceConfig/ReplaceConfig.vcxproj new file mode 100644 index 00000000..c5d7b046 --- /dev/null +++ b/src/test/burn/TestData/PrereqBaTests/ReplaceConfig/ReplaceConfig.vcxproj @@ -0,0 +1,63 @@ + + + + + + + Debug + ARM64 + + + Release + ARM64 + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + {3D10A07D-3321-4F8E-B884-951F8FB5D636} + Application + Console + Unicode + ReplaceConfig + true + + + + + + + comctl32.lib;gdiplus.lib;msimg32.lib;shlwapi.lib;wininet.lib + + + + + Create + + + + + + + + + + + + + diff --git a/src/test/burn/TestData/PrereqBaTests/ReplaceConfig/precomp.cpp b/src/test/burn/TestData/PrereqBaTests/ReplaceConfig/precomp.cpp new file mode 100644 index 00000000..37664a1c --- /dev/null +++ b/src/test/burn/TestData/PrereqBaTests/ReplaceConfig/precomp.cpp @@ -0,0 +1,3 @@ +// 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. + +#include "precomp.h" diff --git a/src/test/burn/TestData/PrereqBaTests/ReplaceConfig/precomp.h b/src/test/burn/TestData/PrereqBaTests/ReplaceConfig/precomp.h new file mode 100644 index 00000000..f4180c2e --- /dev/null +++ b/src/test/burn/TestData/PrereqBaTests/ReplaceConfig/precomp.h @@ -0,0 +1,17 @@ +#pragma once +// 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. + + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "dutil.h" +#include "fileutil.h" +#include "pathutil.h" +#include "strutil.h" diff --git a/src/test/burn/WixTestTools/BundleInstaller.cs b/src/test/burn/WixTestTools/BundleInstaller.cs index 2b449ebf..0ab02d1b 100644 --- a/src/test/burn/WixTestTools/BundleInstaller.cs +++ b/src/test/burn/WixTestTools/BundleInstaller.cs @@ -26,6 +26,20 @@ namespace WixTestTools public string TestName { get; } + /// + /// Runs the bundle asking for help. + /// + /// Expected exit code, defaults to success. + /// Optional arguments to pass to the tool. + /// Path to the generated log file. + public string Help(int expectedExitCode = (int)MSIExec.MSIExecReturnCode.SUCCESS, params string[] arguments) + { + var newArgumentList = new List(); + newArgumentList.Add("-help"); + newArgumentList.AddRange(arguments); + return this.RunBundleWithArguments(expectedExitCode, MSIExec.MSIExecMode.Custom, newArgumentList.ToArray()); + } + /// /// Installs the bundle with optional arguments. /// diff --git a/src/test/burn/WixToolsetTest.BurnE2E/PrereqBaTests.cs b/src/test/burn/WixToolsetTest.BurnE2E/PrereqBaTests.cs index 52e165b4..d958b454 100644 --- a/src/test/burn/WixToolsetTest.BurnE2E/PrereqBaTests.cs +++ b/src/test/burn/WixToolsetTest.BurnE2E/PrereqBaTests.cs @@ -14,6 +14,39 @@ namespace WixToolsetTest.BurnE2E const int E_PREREQBA_INFINITE_LOOP = -2_114_714_646; + /// + /// This bundle purposely provides a .runtimeconfig.json file that requires a version of .NET Core that doesn't exist, + /// with an MSI package to represent the prerequisite package. + /// This verifies that: + /// The preqba doesn't infinitely try to install prereqs. + /// The engine automatically uninstalls the bundle since only permanent packages were installed. + /// + [RuntimeFact] + public void DncAlwaysPreqBaDetectsInfiniteLoop() + { + var packageA = this.CreatePackageInstaller("PackageA"); + var packageC = this.CreatePackageInstaller("PackageC"); + + var bundleC = this.CreateBundleInstaller("BundleC"); + + var packageASourceCodeInstalled = packageA.GetInstalledFilePath("Package.wxs"); + + // Source file should *not* be installed + Assert.False(File.Exists(packageASourceCodeInstalled), $"Package A payload should not be there on test start: {packageASourceCodeInstalled}"); + packageC.VerifyInstalled(false); + + bundleC.Install(E_PREREQBA_INFINITE_LOOP, "CAUSEINFINITELOOP=1"); + + // Part of the test is Install actually completing. + + // Source file should be installed + Assert.True(File.Exists(packageASourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageASourceCodeInstalled)); + packageC.VerifyInstalled(false); + + // No non-permanent packages should have ended up installed or cached so it should have unregistered. + bundleC.VerifyUnregisteredAndRemovedFromPackageCache(); + } + /// /// This bundle purposely provides a .runtimeconfig.json file that requires a version of .NET Core that doesn't exist, /// with an MSI package to represent the prerequisite package. @@ -25,7 +58,7 @@ namespace WixToolsetTest.BurnE2E public void DncPreqBaDetectsInfiniteLoop() { var packageA = this.CreatePackageInstaller("PackageA"); - this.CreatePackageInstaller("PackageF"); + var packageC = this.CreatePackageInstaller("PackageC"); var bundleA = this.CreateBundleInstaller("BundleA"); @@ -33,18 +66,131 @@ namespace WixToolsetTest.BurnE2E // Source file should *not* be installed Assert.False(File.Exists(packageASourceCodeInstalled), $"Package A payload should not be there on test start: {packageASourceCodeInstalled}"); + packageC.VerifyInstalled(false); - bundleA.Install(E_PREREQBA_INFINITE_LOOP); + bundleA.Install(E_PREREQBA_INFINITE_LOOP, "CAUSEINFINITELOOP=1"); // Part of the test is Install actually completing. // Source file should be installed Assert.True(File.Exists(packageASourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageASourceCodeInstalled)); + packageC.VerifyInstalled(false); // No non-permanent packages should have ended up installed or cached so it should have unregistered. bundleA.VerifyUnregisteredAndRemovedFromPackageCache(); } + /// + /// This bundle purposely provides a .runtimeconfig.json file that requires a version of .NET Core that doesn't exist, + /// with an EXE prereq package to swap it out with a good one. + /// This verifies that: + /// The preqba doesn't infinitely try to install prereqs. + /// The managed BA gets loaded after installing prereqs. + /// + [RuntimeFact] + public void DncAlwaysPreqBaLoadsManagedBaAfterInstallingPrereqs() + { + var packageA = this.CreatePackageInstaller("PackageA"); + var packageC = this.CreatePackageInstaller("PackageC"); + + var bundleC = this.CreateBundleInstaller("BundleC"); + + var packageASourceCodeInstalled = packageA.GetInstalledFilePath("Package.wxs"); + + // Source file should *not* be installed + Assert.False(File.Exists(packageASourceCodeInstalled), $"Package A payload should not be there on test start: {packageASourceCodeInstalled}"); + packageC.VerifyInstalled(false); + + bundleC.Install(); + + // Source file should be installed + Assert.True(File.Exists(packageASourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageASourceCodeInstalled)); + packageC.VerifyInstalled(true); + + bundleC.VerifyRegisteredAndInPackageCache(); + + bundleC.Uninstall(); + + bundleC.VerifyUnregisteredAndRemovedFromPackageCache(); + } + + /// + /// This bundle purposely provides a .runtimeconfig.json file that requires a version of .NET Core that doesn't exist, + /// with an EXE prereq package to swap it out with a good one. + /// This verifies that: + /// The preqba doesn't infinitely reload itself after failing to load the managed BA. + /// The managed BA gets loaded after installing prereqs. + /// + [RuntimeFact] + public void DncPreqBaLoadsManagedBaAfterInstallingPrereqs() + { + var packageA = this.CreatePackageInstaller("PackageA"); + var packageC = this.CreatePackageInstaller("PackageC"); + + var bundleA = this.CreateBundleInstaller("BundleA"); + + var packageASourceCodeInstalled = packageA.GetInstalledFilePath("Package.wxs"); + + // Source file should *not* be installed + Assert.False(File.Exists(packageASourceCodeInstalled), $"Package A payload should not be there on test start: {packageASourceCodeInstalled}"); + packageC.VerifyInstalled(false); + + bundleA.Install(); + + // Source file should be installed + Assert.True(File.Exists(packageASourceCodeInstalled), String.Concat("Should have found Package A payload installed at: ", packageASourceCodeInstalled)); + packageC.VerifyInstalled(true); + + bundleA.VerifyRegisteredAndInPackageCache(); + + bundleA.Uninstall(); + + bundleA.VerifyUnregisteredAndRemovedFromPackageCache(); + } + + [RuntimeFact] + public void DncAlwaysPreqBaForwardsHelpToManagedBa() + { + var bundleE = this.CreateBundleInstaller("BundleE"); + + var bundleLog = bundleE.Help(); + + Assert.True(LogVerifier.MessageInLogFile(bundleLog, "This is a BA for automated testing")); + } + + /// + /// This bundle purposely provides a WixToolset.Mba.Host.config file that requires a version of .NET Framework that doesn't exist, + /// with an MSI package to represent the prerequisite package. + /// This verifies that: + /// The preqba doesn't infinitely try to install prereqs. + /// The engine automatically uninstalls the bundle since only permanent packages were installed. + /// + [RuntimeFact] + public void MbaAlwaysPreqBaDetectsInfiniteLoop() + { + var packageB = this.CreatePackageInstaller("PackageB"); + var packageC = this.CreatePackageInstaller("PackageC"); + + var bundleD = this.CreateBundleInstaller("BundleD"); + + var packageBSourceCodeInstalled = packageB.GetInstalledFilePath("Package.wxs"); + + // Source file should *not* be installed + Assert.False(File.Exists(packageBSourceCodeInstalled), $"Package B payload should not be there on test start: {packageBSourceCodeInstalled}"); + packageC.VerifyInstalled(false); + + bundleD.Install(E_PREREQBA_INFINITE_LOOP, "CAUSEINFINITELOOP=1"); + + // Part of the test is Install actually completing. + + // Source file should be installed + Assert.True(File.Exists(packageBSourceCodeInstalled), String.Concat("Should have found Package B payload installed at: ", packageBSourceCodeInstalled)); + packageC.VerifyInstalled(false); + + // No non-permanent packages should have ended up installed or cached so it should have unregistered. + bundleD.VerifyUnregisteredAndRemovedFromPackageCache(); + } + /// /// This bundle purposely provides a WixToolset.Mba.Host.config file that requires a version of .NET Framework that doesn't exist, /// with an MSI package to represent the prerequisite package. @@ -56,7 +202,7 @@ namespace WixToolsetTest.BurnE2E public void MbaPreqBaDetectsInfiniteLoop() { var packageB = this.CreatePackageInstaller("PackageB"); - this.CreatePackageInstaller("PackageF"); + var packageC = this.CreatePackageInstaller("PackageC"); var bundleB = this.CreateBundleInstaller("BundleB"); @@ -64,13 +210,84 @@ namespace WixToolsetTest.BurnE2E // Source file should *not* be installed Assert.False(File.Exists(packageBSourceCodeInstalled), $"Package B payload should not be there on test start: {packageBSourceCodeInstalled}"); + packageC.VerifyInstalled(false); - bundleB.Install(E_PREREQBA_INFINITE_LOOP); + bundleB.Install(E_PREREQBA_INFINITE_LOOP, "CAUSEINFINITELOOP=1"); // Part of the test is Install actually completing. // Source file should be installed Assert.True(File.Exists(packageBSourceCodeInstalled), String.Concat("Should have found Package B payload installed at: ", packageBSourceCodeInstalled)); + packageC.VerifyInstalled(false); + + // No non-permanent packages should have ended up installed or cached so it should have unregistered. + bundleB.VerifyUnregisteredAndRemovedFromPackageCache(); + } + + /// + /// This bundle purposely provides a WixToolset.Mba.Host.config file that requires a version of .NET Framework that doesn't exist, + /// with an EXE prereq package to swap it out with a good one. + /// This verifies that: + /// The preqba doesn't infinitely try to install prereqs. + /// The managed BA gets loaded after installing prereqs. + /// + [RuntimeFact] + public void MbaAlwaysPreqBaLoadsManagedBaAfterInstallingPrereqs() + { + var packageB = this.CreatePackageInstaller("PackageB"); + var packageC = this.CreatePackageInstaller("PackageC"); + + var bundleD = this.CreateBundleInstaller("BundleD"); + + var packageBSourceCodeInstalled = packageB.GetInstalledFilePath("Package.wxs"); + + // Source file should *not* be installed + Assert.False(File.Exists(packageBSourceCodeInstalled), $"Package B payload should not be there on test start: {packageBSourceCodeInstalled}"); + packageC.VerifyInstalled(false); + + bundleD.Install(); + + // Source file should be installed + Assert.True(File.Exists(packageBSourceCodeInstalled), String.Concat("Should have found Package B payload installed at: ", packageBSourceCodeInstalled)); + packageC.VerifyInstalled(true); + + bundleD.VerifyRegisteredAndInPackageCache(); + + bundleD.Uninstall(); + + bundleD.VerifyUnregisteredAndRemovedFromPackageCache(); + } + + /// + /// This bundle purposely provides a WixToolset.Mba.Host.config file that requires a version of .NET Framework that doesn't exist, + /// with an EXE prereq package to swap it out with a good one. + /// This verifies that: + /// The preqba doesn't infinitely reload itself after failing to load the managed BA. + /// The managed BA gets loaded after installing prereqs. + /// + [RuntimeFact] + public void MbaPreqBaLoadsManagedBaAfterInstallingPrereqs() + { + var packageB = this.CreatePackageInstaller("PackageB"); + var packageC = this.CreatePackageInstaller("PackageC"); + + var bundleB = this.CreateBundleInstaller("BundleB"); + + var packageBSourceCodeInstalled = packageB.GetInstalledFilePath("Package.wxs"); + + // Source file should *not* be installed + Assert.False(File.Exists(packageBSourceCodeInstalled), $"Package B payload should not be there on test start: {packageBSourceCodeInstalled}"); + packageC.VerifyInstalled(false); + + bundleB.Install(); + + // Source file should be installed + Assert.True(File.Exists(packageBSourceCodeInstalled), String.Concat("Should have found Package B payload installed at: ", packageBSourceCodeInstalled)); + packageC.VerifyInstalled(true); + + bundleB.VerifyRegisteredAndInPackageCache(); + + bundleB.Uninstall(); // No non-permanent packages should have ended up installed or cached so it should have unregistered. bundleB.VerifyUnregisteredAndRemovedFromPackageCache(); -- cgit v1.2.3-55-g6feb