From 1a38763b97ce53fa99e1d16f739b93135698df41 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Wed, 15 May 2024 22:11:57 -0400 Subject: Add a IUIBA edge-case test and clean up a bit. --- .../InternalUIBAFixture.cs | 70 +++++++++++++++++++++- .../WixIuiBa/CanForceCachePrimaryPackage.wxs | 14 +++++ .../TestData/WixStdBa/Data/preqs.wxl | 38 ++++++++++++ src/ext/Bal/wixext/BalErrors.cs | 5 -- 4 files changed, 120 insertions(+), 7 deletions(-) create mode 100644 src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/TestData/WixIuiBa/CanForceCachePrimaryPackage.wxs create mode 100644 src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/TestData/WixStdBa/Data/preqs.wxl (limited to 'src') diff --git a/src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/InternalUIBAFixture.cs b/src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/InternalUIBAFixture.cs index 7e64c13f..58d5d551 100644 --- a/src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/InternalUIBAFixture.cs +++ b/src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/InternalUIBAFixture.cs @@ -2,11 +2,11 @@ namespace WixToolsetTest.BootstrapperApplications { - using System; using System.IO; using System.Linq; - using WixInternal.TestSupport; + using System.Xml; using WixInternal.Core.TestPackage; + using WixInternal.TestSupport; using Xunit; public class InternalUIBAFixture @@ -194,6 +194,72 @@ namespace WixToolsetTest.BootstrapperApplications } } + [Fact] + public void CanBuildUsingWixIuiBaAndForcedCachePrimaryPackage() + { + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var bundleFile = Path.Combine(baseFolder, "bin", "test.exe"); + var bundleSourceFolder = TestData.Get(@"TestData\WixIuiBa"); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + var baFolderPath = Path.Combine(baseFolder, "ba"); + var extractFolderPath = Path.Combine(baseFolder, "extract"); + + var compileResult = WixRunner.Execute(warningsAsErrors: false, new[] + { + "build", + Path.Combine(bundleSourceFolder, "CanForceCachePrimaryPackage.wxs"), + "-ext", TestData.Get(@"WixToolset.BootstrapperApplications.wixext.dll"), + "-intermediateFolder", intermediateFolder, + "-bindpath", TestData.Get(@"TestData\WixStdBa\Data"), + "-o", bundleFile, + }); + + compileResult.AssertSuccess(); + + Assert.True(File.Exists(bundleFile)); + + var extractResult = BundleExtractor.ExtractBAContainer(null, bundleFile, baFolderPath, extractFolderPath); + extractResult.AssertSuccess(); + + var wixPackageProperties = extractResult.SelectBADataNodes("/ba:BootstrapperApplicationData/ba:WixPackageProperties"); + AssertCacheType(wixPackageProperties[0]); + AssertCacheType(wixPackageProperties[1]); + + var balPackageInfos = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixBalPackageInfo"); + WixAssert.CompareLineByLine(new string[] + { + "", + }, balPackageInfos); + + var mbaPrereqInfos = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixPrereqInformation"); + WixAssert.CompareLineByLine(new[] + { + "", + }, mbaPrereqInfos); + + Assert.True(File.Exists(Path.Combine(baFolderPath, "wixpreq.thm"))); + Assert.True(File.Exists(Path.Combine(baFolderPath, "wixpreq.wxl"))); + } + + static void AssertCacheType(XmlNode node) + { + var element = node as XmlElement; + var package = element?.GetAttribute("Package"); + var cache = element?.GetAttribute("Cache"); + + if (package == "test.msi") + { + Assert.Equal("force", cache); + } + else if (package == "wixnative.exe") + { + Assert.Equal("keep", cache); + } + } + } + [Fact] public void CannotBuildUsingWixIuiBaWithAllPrereqPackages() { diff --git a/src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/TestData/WixIuiBa/CanForceCachePrimaryPackage.wxs b/src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/TestData/WixIuiBa/CanForceCachePrimaryPackage.wxs new file mode 100644 index 00000000..0969a815 --- /dev/null +++ b/src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/TestData/WixIuiBa/CanForceCachePrimaryPackage.wxs @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/TestData/WixStdBa/Data/preqs.wxl b/src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/TestData/WixStdBa/Data/preqs.wxl new file mode 100644 index 00000000..71e8864a --- /dev/null +++ b/src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/TestData/WixStdBa/Data/preqs.wxl @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ext/Bal/wixext/BalErrors.cs b/src/ext/Bal/wixext/BalErrors.cs index 4c719091..d32efe1e 100644 --- a/src/ext/Bal/wixext/BalErrors.cs +++ b/src/ext/Bal/wixext/BalErrors.cs @@ -43,11 +43,6 @@ namespace WixToolset.BootstrapperApplications return Message(sourceLineNumbers, Ids.IuibaPrimaryPackageEnableFeatureSelection, "When using WixInternalUIBootstrapperApplication, primary packages must not have feature selection enabled because it interferes with the user selecting feature through the MSI UI."); } - public static Message MissingDNCBAFactoryAssembly(SourceLineNumber sourceLineNumbers) - { - return Message(sourceLineNumbers, Ids.MissingDNCBAFactoryAssembly, "When using DotNetCoreBootstrapperApplicationHost, the Payload element for the BA's entry point DLL must have bal:BAFactoryAssembly=\"yes\"."); - } - public static Message MissingPrereq(SourceLineNumber sourceLineNumbers) { return Message(sourceLineNumbers, Ids.MissingPrereq, "There must be at least one package with bal:PrereqPackage=\"yes\" when using the bal:WixPrerequisiteBootstrapperApplication."); -- cgit v1.2.3-55-g6feb