From d24800ebb5b9693041d41dbcb7d620e3441c822d Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 22 Feb 2023 00:53:41 -0800 Subject: Allow MsiPackage ForcePerMachine to set the ALLUSERS property Fixes 7232 --- .../PerformBundleBackendValidationCommand.cs | 9 +- .../BundlePackageFixture.cs | 138 +++++++++++++-------- .../TestData/BundleAllUsers/AllUsersPackage.wxs | 14 +++ .../BundleAllUsers/BundleWithAllUsersPackage.wxs | 11 ++ 4 files changed, 122 insertions(+), 50 deletions(-) create mode 100644 src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleAllUsers/AllUsersPackage.wxs create mode 100644 src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleAllUsers/BundleWithAllUsersPackage.wxs (limited to 'src') diff --git a/src/wix/WixToolset.Core.Burn/Bundles/PerformBundleBackendValidationCommand.cs b/src/wix/WixToolset.Core.Burn/Bundles/PerformBundleBackendValidationCommand.cs index 49a25c0a..01df9f32 100644 --- a/src/wix/WixToolset.Core.Burn/Bundles/PerformBundleBackendValidationCommand.cs +++ b/src/wix/WixToolset.Core.Burn/Bundles/PerformBundleBackendValidationCommand.cs @@ -130,7 +130,14 @@ namespace WixToolset.Core.Burn.Bundles private void ValidateMsiProperty(WixBundleMsiPropertySymbol symbol) { - this.BackendHelper.ValidateBundleMsiPropertyName(symbol.SourceLineNumbers, "MsiProperty", "Name", symbol.Name); + // Validate the MSI properties *except* for the ALLUSERS property when set during binding (most likely + // by the MsiPackage/@ForcePerMachine attribute). + var nameField = symbol.Fields[(int)WixBundleMsiPropertySymbolFields.Name]; + var name = nameField.AsString(); + if (name != "ALLUSERS" || nameField.Context != "wix.bind") + { + this.BackendHelper.ValidateBundleMsiPropertyName(symbol.SourceLineNumbers, "MsiProperty", "Name", name); + } if (symbol.Condition != null) { diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/BundlePackageFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/BundlePackageFixture.cs index 2538c0dc..e4ac2dd6 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/BundlePackageFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/BundlePackageFixture.cs @@ -51,16 +51,7 @@ namespace WixToolsetTest.CoreIntegration Assert.True(File.Exists(chainBundlePath)); - string chainBundleId; - using (var wixOutput = WixOutput.Read(chainPdbPath)) - { - - var intermediate = Intermediate.Load(wixOutput); - var section = intermediate.Sections.Single(); - - var bundleSymbol = section.Symbols.OfType().Single(); - chainBundleId = bundleSymbol.BundleId; - } + var chainBundleId = GetBundleIdFromWixpdb(chainPdbPath); // parent.exe result = WixRunner.Execute(new[] @@ -78,16 +69,7 @@ namespace WixToolsetTest.CoreIntegration Assert.True(File.Exists(parentBundlePath)); - string parentBundleId; - using (var wixOutput = WixOutput.Read(parentPdbPath)) - { - - var intermediate = Intermediate.Load(wixOutput); - var section = intermediate.Sections.Single(); - - var bundleSymbol = section.Symbols.OfType().Single(); - parentBundleId = bundleSymbol.BundleId; - } + var parentBundleId = GetBundleIdFromWixpdb(parentPdbPath); var extractResult = BundleExtractor.ExtractBAContainer(null, parentBundlePath, parentBaFolderPath, extractFolderPath); extractResult.AssertSuccess(); @@ -140,16 +122,7 @@ namespace WixToolsetTest.CoreIntegration Assert.True(File.Exists(grandparentBundlePath)); - string grandparentBundleId; - using (var wixOutput = WixOutput.Read(grandparentPdbPath)) - { - - var intermediate = Intermediate.Load(wixOutput); - var section = intermediate.Sections.Single(); - - var bundleSymbol = section.Symbols.OfType().Single(); - grandparentBundleId = bundleSymbol.BundleId; - } + var grandparentBundleId = GetBundleIdFromWixpdb(grandparentPdbPath); var grandparentExtractResult = BundleExtractor.ExtractBAContainer(null, grandparentBundlePath, grandparentBaFolderPath, extractFolderPath); grandparentExtractResult.AssertSuccess(); @@ -229,16 +202,8 @@ namespace WixToolsetTest.CoreIntegration Assert.True(File.Exists(parentBundlePath)); var chainBundleId = "{216BDA7F-74BD-45E8-957B-500552F05629}"; - string parentBundleId; - using (var wixOutput = WixOutput.Read(parentPdbPath)) - { - - var intermediate = Intermediate.Load(wixOutput); - var section = intermediate.Sections.Single(); - var bundleSymbol = section.Symbols.OfType().Single(); - parentBundleId = bundleSymbol.BundleId; - } + var parentBundleId = GetBundleIdFromWixpdb(parentPdbPath); var extractResult = BundleExtractor.ExtractBAContainer(null, parentBundlePath, parentBaFolderPath, extractFolderPath); extractResult.AssertSuccess(); @@ -316,16 +281,7 @@ namespace WixToolsetTest.CoreIntegration Assert.True(File.Exists(parentBundlePath)); - string parentBundleId; - using (var wixOutput = WixOutput.Read(parentPdbPath)) - { - - var intermediate = Intermediate.Load(wixOutput); - var section = intermediate.Sections.Single(); - - var bundleSymbol = section.Symbols.OfType().Single(); - parentBundleId = bundleSymbol.BundleId; - } + var parentBundleId = GetBundleIdFromWixpdb(parentPdbPath); var extractResult = BundleExtractor.ExtractBAContainer(null, parentBundlePath, baFolderPath, extractFolderPath); extractResult.AssertSuccess(); @@ -363,5 +319,89 @@ namespace WixToolsetTest.CoreIntegration }, packageElements); } } + + [Fact] + public void CanBuildBundleWithAllUsersPackage() + { + var folder = TestData.Get("TestData"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var dataPath = Path.Combine(folder, ".Data"); + + var msiIntermediateFolder = Path.Combine(baseFolder, "obj", "msi"); + var msiBinFolder = Path.Combine(baseFolder, "bin", "msi"); + var msiPath = Path.Combine(msiBinFolder, "test.msi"); + + var bundleIntermediateFolder = Path.Combine(baseFolder, "obj", "bundle"); + var bundleBinFolder = Path.Combine(baseFolder, "bin", "bundle"); + var bundlePath = Path.Combine(bundleBinFolder, "bundle.exe"); + var bundlePdbPath = Path.Combine(bundleBinFolder, "bundle.wixpdb"); + + var baFolderPath = Path.Combine(baseFolder, "extract", "ba"); + var extractFolderPath = Path.Combine(baseFolder, "extract", "files"); + + var result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "BundleAllUsers", "AllUsersPackage.wxs"), + "-bindpath", dataPath, + "-intermediateFolder", msiIntermediateFolder, + "-o", msiPath + }); + + result.AssertSuccess(); + + result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "BundleAllUsers", "BundleWithAllUsersPackage.wxs"), + "-bindpath", dataPath, + "-bindpath", msiBinFolder, + "-intermediateFolder", bundleIntermediateFolder, + "-o", bundlePath + }); + + result.AssertSuccess(); + + var parentBundleId = GetBundleIdFromWixpdb(bundlePdbPath); + + var extractResult = BundleExtractor.ExtractBAContainer(null, bundlePath, baFolderPath, extractFolderPath); + extractResult.AssertSuccess(); + + var registrations = extractResult.GetManifestTestXmlLines("/burn:BurnManifest/burn:Registration"); + WixAssert.CompareLineByLine(new[] + { + $"" + + "" + + "" + }, registrations); + + var ignoreAttributesByElementName = new Dictionary> + { + { "WixPackageProperties", new List { "DownloadSize", "PackageSize" } }, + }; + + var packageElements = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixPackageProperties", ignoreAttributesByElementName); + WixAssert.CompareLineByLine(new[] + { + "", + }, packageElements); + } + } + + private static string GetBundleIdFromWixpdb(string bundlePdbPath) + { + using (var wixOutput = WixOutput.Read(bundlePdbPath)) + { + + var intermediate = Intermediate.Load(wixOutput); + var section = intermediate.Sections.Single(); + + var bundleSymbol = section.Symbols.OfType().Single(); + return bundleSymbol.BundleId; + } + } } } diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleAllUsers/AllUsersPackage.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleAllUsers/AllUsersPackage.wxs new file mode 100644 index 00000000..63046563 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleAllUsers/AllUsersPackage.wxs @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleAllUsers/BundleWithAllUsersPackage.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleAllUsers/BundleWithAllUsersPackage.wxs new file mode 100644 index 00000000..6344e861 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleAllUsers/BundleWithAllUsersPackage.wxs @@ -0,0 +1,11 @@ + + + + + + + + + + + -- cgit v1.2.3-55-g6feb