Skip to content

Commit 8ebde13

Browse files
charles-juicelabsrobmen
authored andcommitted
Add bal:DisplayFilesInUseDialogCondition to disable Files In Use dialog
Disabling display skips showing the "Files In Use" dialog and returning a result as if the user had chosen to ignore the dialog and reboot in the case of files that were unable to be replaced.
1 parent 2a58247 commit 8ebde13

File tree

15 files changed

+169
-20
lines changed

15 files changed

+169
-20
lines changed

src/api/burn/WixToolset.BootstrapperApplicationApi/IPackageInfo.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ public interface IPackageInfo
2727
/// </summary>
2828
string DisplayInternalUICondition { get; }
2929

30+
/// <summary>
31+
/// The authored bal:DisplayFilesInUseDialogCondition.
32+
/// </summary>
33+
string DisplayFilesInUseDialogCondition { get; }
34+
3035
/// <summary>
3136
/// The package's display name.
3237
/// </summary>

src/api/burn/WixToolset.BootstrapperApplicationApi/PackageInfo.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ public class PackageInfo : IPackageInfo
120120
/// <inheritdoc/>
121121
public string DisplayInternalUICondition { get; internal set; }
122122

123+
/// <inheritdoc/>
124+
public string DisplayFilesInUseDialogCondition { get; internal set; }
125+
123126
/// <inheritdoc/>
124127
public string ProductCode { get; internal set; }
125128

@@ -363,6 +366,7 @@ internal static void ParseBalPackageInfoFromXml(XPathNavigator root, XmlNamespac
363366
var package = (PackageInfo)ipackage;
364367

365368
package.DisplayInternalUICondition = BootstrapperApplicationData.GetAttribute(node, "DisplayInternalUICondition");
369+
package.DisplayFilesInUseDialogCondition = BootstrapperApplicationData.GetAttribute(node, "DisplayFilesInUseDialogCondition");
366370
}
367371

368372
nodes = root.Select("/p:BootstrapperApplicationData/p:WixPrereqInformation", namespaceManager);

src/api/burn/balutil/balinfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ DAPI_(void) BalInfoUninitialize(
291291
ReleaseStr(pBundle->packages.rgPackages[i].sczDescription);
292292
ReleaseStr(pBundle->packages.rgPackages[i].sczId);
293293
ReleaseStr(pBundle->packages.rgPackages[i].sczDisplayInternalUICondition);
294+
ReleaseStr(pBundle->packages.rgPackages[i].sczDisplayFilesInUseDialogCondition);
294295
ReleaseStr(pBundle->packages.rgPackages[i].sczProductCode);
295296
ReleaseStr(pBundle->packages.rgPackages[i].sczUpgradeCode);
296297
ReleaseStr(pBundle->packages.rgPackages[i].sczVersion);
@@ -517,6 +518,9 @@ static HRESULT ParseBalPackageInfoFromXml(
517518
hr = XmlGetAttributeEx(pNode, L"DisplayInternalUICondition", &pPackage->sczDisplayInternalUICondition);
518519
ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get DisplayInternalUICondition setting for package.");
519520

521+
hr = XmlGetAttributeEx(pNode, L"DisplayFilesInUseDialogCondition", &pPackage->sczDisplayFilesInUseDialogCondition);
522+
ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get DisplayFilesInUseDialogCondition setting for package.");
523+
520524
hr = XmlGetAttributeEx(pNode, L"PrimaryPackageType", &scz);
521525
ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get PrimaryPackageType setting for package.");
522526

src/api/burn/balutil/inc/balinfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ typedef struct _BAL_INFO_PACKAGE
5454
BOOL fPermanent;
5555
BOOL fVital;
5656
LPWSTR sczDisplayInternalUICondition;
57+
LPWSTR sczDisplayFilesInUseDialogCondition;
5758
LPWSTR sczProductCode;
5859
LPWSTR sczUpgradeCode;
5960
LPWSTR sczVersion;

src/ext/Bal/stdbas/WixStandardBootstrapperApplication.cpp

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,34 +1231,52 @@ class CWixStandardBootstrapperApplication : public CBootstrapperApplicationBase
12311231
__inout int* pResult
12321232
)
12331233
{
1234+
HRESULT hr = S_OK;
1235+
BAL_INFO_PACKAGE* pPackage = NULL;
1236+
BOOL fShowFilesInUseDialog = TRUE;
12341237

12351238
if (!m_fShowingInternalUiThisPackage && wzPackageId && *wzPackageId)
12361239
{
12371240
BalLog(BOOTSTRAPPER_LOG_LEVEL_VERBOSE, "Package %ls has %d applications holding files in use.", wzPackageId, cFiles);
12381241

1239-
switch (source)
1242+
hr = BalInfoFindPackageById(&m_Bundle.packages, wzPackageId, &pPackage);
1243+
if (SUCCEEDED(hr) && pPackage->sczDisplayFilesInUseDialogCondition)
12401244
{
1241-
case BOOTSTRAPPER_FILES_IN_USE_TYPE_MSI:
1242-
if (m_fShowStandardFilesInUse)
1243-
{
1244-
return ShowMsiFilesInUse(cFiles, rgwzFiles, source, pResult);
1245-
}
1246-
break;
1247-
case BOOTSTRAPPER_FILES_IN_USE_TYPE_MSI_RM:
1248-
if (m_fShowRMFilesInUse)
1249-
{
1250-
return ShowMsiFilesInUse(cFiles, rgwzFiles, source, pResult);
1251-
}
1252-
break;
1253-
case BOOTSTRAPPER_FILES_IN_USE_TYPE_NETFX:
1254-
if (m_fShowNetfxFilesInUse)
1245+
hr = BalEvaluateCondition(pPackage->sczDisplayFilesInUseDialogCondition, &fShowFilesInUseDialog);
1246+
BalExitOnFailure(hr, "Failed to evaluate condition for package '%ls': %ls", wzPackageId, pPackage->sczDisplayFilesInUseDialogCondition);
1247+
}
1248+
1249+
if (fShowFilesInUseDialog)
1250+
{
1251+
switch (source)
12551252
{
1256-
return ShowNetfxFilesInUse(cFiles, rgwzFiles, pResult);
1253+
case BOOTSTRAPPER_FILES_IN_USE_TYPE_MSI:
1254+
if (m_fShowStandardFilesInUse)
1255+
{
1256+
return ShowMsiFilesInUse(cFiles, rgwzFiles, source, pResult);
1257+
}
1258+
break;
1259+
case BOOTSTRAPPER_FILES_IN_USE_TYPE_MSI_RM:
1260+
if (m_fShowRMFilesInUse)
1261+
{
1262+
return ShowMsiFilesInUse(cFiles, rgwzFiles, source, pResult);
1263+
}
1264+
break;
1265+
case BOOTSTRAPPER_FILES_IN_USE_TYPE_NETFX:
1266+
if (m_fShowNetfxFilesInUse)
1267+
{
1268+
return ShowNetfxFilesInUse(cFiles, rgwzFiles, pResult);
1269+
}
1270+
break;
12571271
}
1258-
break;
1272+
}
1273+
else
1274+
{
1275+
*pResult = IDIGNORE;
12591276
}
12601277
}
12611278

1279+
LExit:
12621280
return __super::OnExecuteFilesInUse(wzPackageId, cFiles, rgwzFiles, nRecommendation, source, pResult);
12631281
}
12641282

src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/BalExtensionFixture.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,44 @@ public void CanBuildUsingDisplayInternalUICondition()
5555
}
5656
}
5757

58+
[TestMethod]
59+
public void CanBuildUsingDisplayFilesInUseDialogCondition()
60+
{
61+
using (var fs = new DisposableFileSystem())
62+
{
63+
var baseFolder = fs.GetFolder();
64+
var bundleFile = Path.Combine(baseFolder, "bin", "test.exe");
65+
var bundleSourceFolder = TestData.Get(@"TestData\WixStdBa");
66+
var intermediateFolder = Path.Combine(baseFolder, "obj");
67+
var baFolderPath = Path.Combine(baseFolder, "ba");
68+
var extractFolderPath = Path.Combine(baseFolder, "extract");
69+
70+
var compileResult = WixRunner.Execute(new[]
71+
{
72+
"build",
73+
Path.Combine(bundleSourceFolder, "DisplayFilesInUseDialogConditionBundle.wxs"),
74+
"-ext", TestData.Get(@"WixToolset.BootstrapperApplications.wixext.dll"),
75+
"-intermediateFolder", intermediateFolder,
76+
"-bindpath", Path.Combine(bundleSourceFolder, "data"),
77+
"-o", bundleFile,
78+
});
79+
compileResult.AssertSuccess();
80+
81+
Assert.IsTrue(File.Exists(bundleFile));
82+
83+
var extractResult = BundleExtractor.ExtractBAContainer(null, bundleFile, baFolderPath, extractFolderPath);
84+
extractResult.AssertSuccess();
85+
86+
var balPackageInfos = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixBalPackageInfo");
87+
WixAssert.CompareLineByLine(new string[]
88+
{
89+
"<WixBalPackageInfo PackageId='test.msi' DisplayFilesInUseDialogCondition='1' />",
90+
}, balPackageInfos);
91+
92+
Assert.IsTrue(File.Exists(Path.Combine(baFolderPath, "thm.wxl")));
93+
}
94+
}
95+
5896
[TestMethod]
5997
public void CanBuildUsingBootstrapperApplicationId()
6098
{
@@ -298,6 +336,7 @@ public void CannotBuildUsingOverridableWrongCase()
298336
{
299337
"bal:Condition/@Condition contains the built-in Variable 'WixBundleAction', which is not available when it is evaluated. (Unavailable Variables are: 'WixBundleAction'.). Rewrite the condition to avoid Variables that are never valid during its evaluation.",
300338
"Overridable variable 'TEST1' collides with 'Test1' with Bundle/@CommandLineVariables value 'caseInsensitive'.",
339+
"The *Package/@bal:DisplayFilesInUseDialogCondition attribute's value '=' is not a valid bundle condition.",
301340
"The *Package/@bal:DisplayInternalUICondition attribute's value '=' is not a valid bundle condition.",
302341
"The location of the Variable related to the previous error.",
303342
}, messages.ToArray());

src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/InternalUIBAFixture.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ public void CanBuildUsingWixIuiBaWithWarnings()
168168
"WixInternalUIBootstrapperApplication does not support the value of 'force' for Cache on prereq packages. Prereq packages are only cached when they need to be installed.",
169169
"WixInternalUIBootstrapperApplication ignores InstallCondition for the primary package so that the MSI UI is always shown.",
170170
"WixInternalUIBootstrapperApplication ignores DisplayInternalUICondition for the primary package so that the MSI UI is always shown.",
171+
"WixInternalUIBootstrapperApplication ignores DisplayFilesInUseDialogCondition for the primary package so that the MSI UI is always shown.",
171172
"When using WixInternalUIBootstrapperApplication, all prereq packages should be before the primary package in the chain. The prereq packages are always installed before the primary package.",
172173
}, compileResult.Messages.Select(m => m.ToString()).ToArray());
173174

@@ -181,7 +182,7 @@ public void CanBuildUsingWixIuiBaWithWarnings()
181182
var balPackageInfos = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixBalPackageInfo");
182183
WixAssert.CompareLineByLine(new string[]
183184
{
184-
"<WixBalPackageInfo PackageId='test.msi' DisplayInternalUICondition='DISPLAYTEST' PrimaryPackageType='default' />",
185+
"<WixBalPackageInfo PackageId='test.msi' DisplayInternalUICondition='DISPLAYTEST' DisplayFilesInUseDialogCondition='DISPLAYTEST' PrimaryPackageType='default' />",
185186
}, balPackageInfos);
186187

187188
var mbaPrereqInfos = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixPrereqInformation");

src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/TestData/Overridable/WrongCaseBundle.wxs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<Variable Name="TEST1" bal:Overridable="yes" />
1010
<Chain>
1111
<ExePackage Permanent="yes" DetectCondition="none" SourceFile="runtimes\win-x86\native\wixnative.exe" />
12-
<MsiPackage SourceFile="test.msi" bal:DisplayInternalUICondition="!(loc.NonsensePlanCondition)" />
12+
<MsiPackage SourceFile="test.msi" bal:DisplayInternalUICondition="!(loc.NonsensePlanCondition)" bal:DisplayFilesInUseDialogCondition="!(loc.NonsensePlanCondition)" />
1313
</Chain>
1414
<bal:Condition Condition="!(loc.NonsenseDetectCondition)" Message="Unsupported" />
1515
</Bundle>

src/ext/Bal/test/WixToolsetTest.BootstrapperApplications/TestData/WixIuiBa/IuibaWarnings.wxs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<bal:WixInternalUIBootstrapperApplication />
77
</BootstrapperApplication>
88
<Chain>
9-
<MsiPackage SourceFile="test.msi" InstallCondition="INSTALLTEST" bal:DisplayInternalUICondition="DISPLAYTEST" />
9+
<MsiPackage SourceFile="test.msi" InstallCondition="INSTALLTEST" bal:DisplayInternalUICondition="DISPLAYTEST" bal:DisplayFilesInUseDialogCondition="DISPLAYTEST" />
1010
<ExePackage Permanent="yes" DetectCondition="none" SourceFile="runtimes\win-x86\native\wixnative.exe" Cache="force" />
1111
</Chain>
1212
</Bundle>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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="WixStdBa" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="75D5D534-E177-4689-AAE9-CAC1C39002C2">
5+
<BootstrapperApplication>
6+
<bal:WixStandardBootstrapperApplication LicenseUrl="http://wixtoolset.org/about/license/" Theme="hyperlinkLicense" />
7+
</BootstrapperApplication>
8+
<Chain>
9+
<MsiPackage SourceFile="test.msi" bal:DisplayFilesInUseDialogCondition="1" />
10+
</Chain>
11+
</Bundle>
12+
</Wix>

0 commit comments

Comments
 (0)