@joebigelow / wix / commits / 1a38763b

Add a IUIBA edge-case test and clean up a bit.

Bob Arnson committed May 15, 2024 at 22:11 UTC 1a38763b97ce53fa99e1d16f739b93135698df41
4 files changed +120 -7
src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/InternalUIBAFixture.cs
+68 -2
@@ -2,11 +2,11 @@
2
3 namespace WixToolsetTest.BootstrapperApplications
4 {
5 - using System;
5 using System.IO;
6 using System.Linq;
8 - using WixInternal.TestSupport;
7 + using System.Xml;
8 using WixInternal.Core.TestPackage;
9 + using WixInternal.TestSupport;
10 using Xunit;
11
12 public class InternalUIBAFixture
@@ -194,6 +194,72 @@ namespace WixToolsetTest.BootstrapperApplications
194 }
195 }
196
197 + [Fact]
198 + public void CanBuildUsingWixIuiBaAndForcedCachePrimaryPackage()
199 + {
200 + using (var fs = new DisposableFileSystem())
201 + {
202 + var baseFolder = fs.GetFolder();
203 + var bundleFile = Path.Combine(baseFolder, "bin", "test.exe");
204 + var bundleSourceFolder = TestData.Get(@"TestData\WixIuiBa");
205 + var intermediateFolder = Path.Combine(baseFolder, "obj");
206 + var baFolderPath = Path.Combine(baseFolder, "ba");
207 + var extractFolderPath = Path.Combine(baseFolder, "extract");
208 +
209 + var compileResult = WixRunner.Execute(warningsAsErrors: false, new[]
210 + {
211 + "build",
212 + Path.Combine(bundleSourceFolder, "CanForceCachePrimaryPackage.wxs"),
213 + "-ext", TestData.Get(@"WixToolset.BootstrapperApplications.wixext.dll"),
214 + "-intermediateFolder", intermediateFolder,
215 + "-bindpath", TestData.Get(@"TestData\WixStdBa\Data"),
216 + "-o", bundleFile,
217 + });
218 +
219 + compileResult.AssertSuccess();
220 +
221 + Assert.True(File.Exists(bundleFile));
222 +
223 + var extractResult = BundleExtractor.ExtractBAContainer(null, bundleFile, baFolderPath, extractFolderPath);
224 + extractResult.AssertSuccess();
225 +
226 + var wixPackageProperties = extractResult.SelectBADataNodes("/ba:BootstrapperApplicationData/ba:WixPackageProperties");
227 + AssertCacheType(wixPackageProperties[0]);
228 + AssertCacheType(wixPackageProperties[1]);
229 +
230 + var balPackageInfos = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixBalPackageInfo");
231 + WixAssert.CompareLineByLine(new string[]
232 + {
233 + "<WixBalPackageInfo PackageId='test.msi' PrimaryPackageType='default' />",
234 + }, balPackageInfos);
235 +
236 + var mbaPrereqInfos = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixPrereqInformation");
237 + WixAssert.CompareLineByLine(new[]
238 + {
239 + "<WixPrereqInformation PackageId='wixnative.exe' />",
240 + }, mbaPrereqInfos);
241 +
242 + Assert.True(File.Exists(Path.Combine(baFolderPath, "wixpreq.thm")));
243 + Assert.True(File.Exists(Path.Combine(baFolderPath, "wixpreq.wxl")));
244 + }
245 +
246 + static void AssertCacheType(XmlNode node)
247 + {
248 + var element = node as XmlElement;
249 + var package = element?.GetAttribute("Package");
250 + var cache = element?.GetAttribute("Cache");
251 +
252 + if (package == "test.msi")
253 + {
254 + Assert.Equal("force", cache);
255 + }
256 + else if (package == "wixnative.exe")
257 + {
258 + Assert.Equal("keep", cache);
259 + }
260 + }
261 + }
262 +
263 [Fact]
264 public void CannotBuildUsingWixIuiBaWithAllPrereqPackages()
265 {
src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/TestData/WixIuiBa/CanForceCachePrimaryPackage.wxs new
+14
@@ -0,0 +1,14 @@
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
3 + xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal">
4 + <Bundle Name="WixIuiBa" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="{1CD73801-0B08-4B39-B371-00DA49EF715F}">
5 + <BootstrapperApplication>
6 + <Payload SourceFile="preqs.wxl" />
7 + <bal:WixInternalUIBootstrapperApplication LocalizationFile="preqs.wxl" />
8 + </BootstrapperApplication>
9 + <Chain>
10 + <ExePackage Permanent="yes" DetectCondition="none" SourceFile="runtimes\win-x86\native\wixnative.exe" />
11 + <MsiPackage SourceFile="test.msi" Cache="force" />
12 + </Chain>
13 + </Bundle>
14 +</Wix>
src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/TestData/WixStdBa/Data/preqs.wxl new
+38
@@ -0,0 +1,38 @@
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 +<WixLocalization Culture="en-us" Language="1033" xmlns="http://wixtoolset.org/schemas/v4/wxl">
5 + <String Id="Caption" Value="[WixBundleName] Prerequisites Setup" />
6 + <String Id="Title" Value="Prerequisites required for [WixBundleName] setup" />
7 + <String Id="NonPrereqTitle" Value="[WixBundleName] setup" />
8 + <String Id="ConfirmCancelMessage" Value="Are you sure you want to cancel?" />
9 + <String Id="HelpHeader" Value="Setup Help" />
10 + <String Id="HelpText" Value="/passive | /quiet - displays minimal UI with no prompts or displays no UI and&#xA; no prompts. By default UI and all prompts are displayed.&#xA;&#xA;/norestart - suppress any attempts to restart. By default UI will prompt before restart.&#xA;/log log.txt - logs to a specific file. By default a log file is created in %TEMP%." />
11 + <String Id="HelpCloseButton" Value="&amp;Close" />
12 + <String Id="InstallLicenseTerms" Value="Click the &quot;Install&quot; button to accept the prerequisite &lt;a href=&quot;#&quot;&gt;license terms&lt;/a&gt;." />
13 + <String Id="InstallAcceptAndInstallButton" Value="&amp;Install" />
14 + <String Id="InstallDeclineButton" Value="&amp;Decline" />
15 + <String Id="ProgressHeader" Value="Setup Progress" />
16 + <String Id="ProgressLabel" Value="Processing:" />
17 + <String Id="ProgressCancelButton" Value="&amp;Cancel" />
18 + <String Id="SuccessHeader" Value="Prerequisite Setup Successful" />
19 + <String Id="SuccessLayoutHeader" Value="Layout Successfully Completed" />
20 + <String Id="SuccessRestartText" Value="You must restart your computer before [WixBundleName] setup can continue." />
21 + <String Id="SuccessRestartButton" Value="&amp;Restart" />
22 + <String Id="SuccessCloseButton" Value="&amp;Close" />
23 + <String Id="FailureHeader" Value="Setup Failed" />
24 + <String Id="FailureLayoutHeader" Value="Layout Failed" />
25 + <String Id="FailureLogLinkText" Value="One or more issues caused the setup to fail. Please fix the issues and then retry setup. For more information see the &lt;a href=&quot;#&quot;&gt;log file&lt;/a&gt;." />
26 + <String Id="FailureRestartText" Value="You must restart your computer to complete the rollback of the software." />
27 + <String Id="FailureRestartButton" Value="&amp;Restart" />
28 + <String Id="FailureCloseButton" Value="&amp;Close" />
29 + <String Id="PREREQBAINFINITELOOPErrorMessage" Value="[WixBundleName] failed to start even though all of the prerequisites are installed." />
30 + <String Id="FilesInUseTitle" Value="Files In Use" />
31 + <String Id="FilesInUseLabel" Value="The following applications are using files that need to be updated:" />
32 + <String Id="FilesInUseNetfxCloseRadioButton" Value="Close the &amp;applications." />
33 + <String Id="FilesInUseCloseRadioButton" Value="Close the &amp;applications and attempt to restart them." />
34 + <String Id="FilesInUseDontCloseRadioButton" Value="&amp;Do not close applications. A reboot will be required." />
35 + <String Id="FilesInUseRetryButton" Value="&amp;Retry" />
36 + <String Id="FilesInUseIgnoreButton" Value="&amp;Ignore" />
37 + <String Id="FilesInUseExitButton" Value="E&amp;xit" />
38 +</WixLocalization>
src/ext/Bal/wixext/BalErrors.cs
-5
@@ -43,11 +43,6 @@ namespace WixToolset.BootstrapperApplications
43 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.");
44 }
45
46 - public static Message MissingDNCBAFactoryAssembly(SourceLineNumber sourceLineNumbers)
47 - {
48 - return Message(sourceLineNumbers, Ids.MissingDNCBAFactoryAssembly, "When using DotNetCoreBootstrapperApplicationHost, the Payload element for the BA's entry point DLL must have bal:BAFactoryAssembly=\"yes\".");
49 - }
50 -
46 public static Message MissingPrereq(SourceLineNumber sourceLineNumbers)
47 {
48 return Message(sourceLineNumbers, Ids.MissingPrereq, "There must be at least one package with bal:PrereqPackage=\"yes\" when using the bal:WixPrerequisiteBootstrapperApplication.");