Skip to content

Commit

Permalink
Add a IUIBA edge-case test and clean up a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
barnson committed Jun 11, 2024
1 parent eed1b5b commit f48bd12
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -194,6 +194,72 @@ public void CanBuildUsingWixIuiBaWithWarnings()
}
}

[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[]
{
"<WixBalPackageInfo PackageId='test.msi' PrimaryPackageType='default' />",
}, balPackageInfos);

var mbaPrereqInfos = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixPrereqInformation");
WixAssert.CompareLineByLine(new[]
{
"<WixPrereqInformation PackageId='wixnative.exe' />",
}, 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()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal">
<Bundle Name="WixIuiBa" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="{1CD73801-0B08-4B39-B371-00DA49EF715F}">
<BootstrapperApplication>
<Payload SourceFile="preqs.wxl" />
<bal:WixInternalUIBootstrapperApplication LocalizationFile="preqs.wxl" />
</BootstrapperApplication>
<Chain>
<ExePackage Permanent="yes" DetectCondition="none" SourceFile="runtimes\win-x86\native\wixnative.exe" />
<MsiPackage SourceFile="test.msi" Cache="force" />
</Chain>
</Bundle>
</Wix>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!-- 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. -->


<WixLocalization Culture="en-us" Language="1033" xmlns="http://wixtoolset.org/schemas/v4/wxl">
<String Id="Caption" Value="[WixBundleName] Prerequisites Setup" />
<String Id="Title" Value="Prerequisites required for [WixBundleName] setup" />
<String Id="NonPrereqTitle" Value="[WixBundleName] setup" />
<String Id="ConfirmCancelMessage" Value="Are you sure you want to cancel?" />
<String Id="HelpHeader" Value="Setup Help" />
<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%." />
<String Id="HelpCloseButton" Value="&amp;Close" />
<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;." />
<String Id="InstallAcceptAndInstallButton" Value="&amp;Install" />
<String Id="InstallDeclineButton" Value="&amp;Decline" />
<String Id="ProgressHeader" Value="Setup Progress" />
<String Id="ProgressLabel" Value="Processing:" />
<String Id="ProgressCancelButton" Value="&amp;Cancel" />
<String Id="SuccessHeader" Value="Prerequisite Setup Successful" />
<String Id="SuccessLayoutHeader" Value="Layout Successfully Completed" />
<String Id="SuccessRestartText" Value="You must restart your computer before [WixBundleName] setup can continue." />
<String Id="SuccessRestartButton" Value="&amp;Restart" />
<String Id="SuccessCloseButton" Value="&amp;Close" />
<String Id="FailureHeader" Value="Setup Failed" />
<String Id="FailureLayoutHeader" Value="Layout Failed" />
<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;." />
<String Id="FailureRestartText" Value="You must restart your computer to complete the rollback of the software." />
<String Id="FailureRestartButton" Value="&amp;Restart" />
<String Id="FailureCloseButton" Value="&amp;Close" />
<String Id="PREREQBAINFINITELOOPErrorMessage" Value="[WixBundleName] failed to start even though all of the prerequisites are installed." />
<String Id="FilesInUseTitle" Value="Files In Use" />
<String Id="FilesInUseLabel" Value="The following applications are using files that need to be updated:" />
<String Id="FilesInUseNetfxCloseRadioButton" Value="Close the &amp;applications." />
<String Id="FilesInUseCloseRadioButton" Value="Close the &amp;applications and attempt to restart them." />
<String Id="FilesInUseDontCloseRadioButton" Value="&amp;Do not close applications. A reboot will be required." />
<String Id="FilesInUseRetryButton" Value="&amp;Retry" />
<String Id="FilesInUseIgnoreButton" Value="&amp;Ignore" />
<String Id="FilesInUseExitButton" Value="E&amp;xit" />
</WixLocalization>
5 changes: 0 additions & 5 deletions src/ext/Bal/wixext/BalErrors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ public static Message IuibaPrimaryPackageEnableFeatureSelection(SourceLineNumber
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.");
Expand Down

0 comments on commit f48bd12

Please sign in to comment.