diff options
| author | Rob Mensching <rob@firegiant.com> | 2023-01-12 16:15:31 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2023-01-12 17:18:08 -0800 |
| commit | e74bc9e2bcca9ba4378e8a9c87f5081295616902 (patch) | |
| tree | eff79906fb5d79c0f2c49c1ea71dd8ff4fc7aa83 /src | |
| parent | e3b4af31d93962a7bd0a417d400921e00e9e249a (diff) | |
| download | wix-e74bc9e2bcca9ba4378e8a9c87f5081295616902.tar.gz wix-e74bc9e2bcca9ba4378e8a9c87f5081295616902.tar.bz2 wix-e74bc9e2bcca9ba4378e8a9c87f5081295616902.zip | |
Add support for ALLUSERS=2 with Scope=perUserOrMachine
Fixes 7137
Diffstat (limited to 'src')
5 files changed, 133 insertions, 1 deletions
diff --git a/src/wix/WixToolset.Core/Compiler_Package.cs b/src/wix/WixToolset.Core/Compiler_Package.cs index e59c394a..e0b8a3f6 100644 --- a/src/wix/WixToolset.Core/Compiler_Package.cs +++ b/src/wix/WixToolset.Core/Compiler_Package.cs | |||
| @@ -31,6 +31,7 @@ namespace WixToolset.Core | |||
| 31 | var productCode = "*"; | 31 | var productCode = "*"; |
| 32 | string productLanguage = null; | 32 | string productLanguage = null; |
| 33 | var isPerMachine = true; | 33 | var isPerMachine = true; |
| 34 | var isPerUserOrMachine = false; | ||
| 34 | string upgradeCode = null; | 35 | string upgradeCode = null; |
| 35 | string manufacturer = null; | 36 | string manufacturer = null; |
| 36 | string version = null; | 37 | string version = null; |
| @@ -91,6 +92,10 @@ namespace WixToolset.Core | |||
| 91 | isPerMachine = false; | 92 | isPerMachine = false; |
| 92 | sourceBits |= 8; | 93 | sourceBits |= 8; |
| 93 | break; | 94 | break; |
| 95 | case "perUserOrMachine": | ||
| 96 | isPerMachine = false; | ||
| 97 | isPerUserOrMachine = true; | ||
| 98 | break; | ||
| 94 | default: | 99 | default: |
| 95 | this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, installScope, "perMachine", "perUser")); | 100 | this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, installScope, "perMachine", "perUser")); |
| 96 | break; | 101 | break; |
| @@ -169,7 +174,12 @@ namespace WixToolset.Core | |||
| 169 | this.AddProperty(sourceLineNumbers, new Identifier(AccessModifier.Global, "UpgradeCode"), upgradeCode, false, false, false, true); | 174 | this.AddProperty(sourceLineNumbers, new Identifier(AccessModifier.Global, "UpgradeCode"), upgradeCode, false, false, false, true); |
| 170 | } | 175 | } |
| 171 | 176 | ||
| 172 | if (isPerMachine) | 177 | if (isPerUserOrMachine) |
| 178 | { | ||
| 179 | this.AddProperty(sourceLineNumbers, new Identifier(AccessModifier.Global, "ALLUSERS"), "2", false, false, false, false); | ||
| 180 | this.AddProperty(sourceLineNumbers, new Identifier(AccessModifier.Global, "MSIINSTALLPERUSER"), "1", false, false, false, false); | ||
| 181 | } | ||
| 182 | else if (isPerMachine) | ||
| 173 | { | 183 | { |
| 174 | this.AddProperty(sourceLineNumbers, new Identifier(AccessModifier.Global, "ALLUSERS"), "1", false, false, false, false); | 184 | this.AddProperty(sourceLineNumbers, new Identifier(AccessModifier.Global, "ALLUSERS"), "1", false, false, false, false); |
| 175 | } | 185 | } |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/AllUsersFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/AllUsersFixture.cs new file mode 100644 index 00000000..0c1fd9e0 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/AllUsersFixture.cs | |||
| @@ -0,0 +1,77 @@ | |||
| 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 | namespace WixToolsetTest.CoreIntegration | ||
| 4 | { | ||
| 5 | using System.IO; | ||
| 6 | using System.Linq; | ||
| 7 | using WixInternal.Core.TestPackage; | ||
| 8 | using WixInternal.TestSupport; | ||
| 9 | using Xunit; | ||
| 10 | |||
| 11 | public class AllUsersFixture | ||
| 12 | { | ||
| 13 | [Fact] | ||
| 14 | public void CanCheckPerMachineMsi() | ||
| 15 | { | ||
| 16 | var propertyRows = BuildAndQueryPropertyTable("PerMachine.wxs"); | ||
| 17 | |||
| 18 | WixAssert.CompareLineByLine(new[] | ||
| 19 | { | ||
| 20 | "_SummaryInformation:WordCount\t2", | ||
| 21 | "Property:ALLUSERS\t1" | ||
| 22 | }, propertyRows); | ||
| 23 | } | ||
| 24 | |||
| 25 | [Fact] | ||
| 26 | public void CanCheckPerUserMsi() | ||
| 27 | { | ||
| 28 | var propertyRows = BuildAndQueryPropertyTable("PerUser.wxs"); | ||
| 29 | |||
| 30 | WixAssert.CompareLineByLine(new[] | ||
| 31 | { | ||
| 32 | "_SummaryInformation:WordCount\t10" | ||
| 33 | }, propertyRows); | ||
| 34 | } | ||
| 35 | |||
| 36 | [Fact] | ||
| 37 | public void CanCheckPerUserOrMachineMsi() | ||
| 38 | { | ||
| 39 | var propertyRows = BuildAndQueryPropertyTable("PerUserOrMachine.wxs"); | ||
| 40 | |||
| 41 | WixAssert.CompareLineByLine(new[] | ||
| 42 | { | ||
| 43 | "_SummaryInformation:WordCount\t2", | ||
| 44 | "Property:ALLUSERS\t2", | ||
| 45 | "Property:MSIINSTALLPERUSER\t1" | ||
| 46 | }, propertyRows); | ||
| 47 | } | ||
| 48 | |||
| 49 | private static string[] BuildAndQueryPropertyTable(string file) | ||
| 50 | { | ||
| 51 | var folder = TestData.Get("TestData", "AllUsers"); | ||
| 52 | |||
| 53 | using (var fs = new DisposableFileSystem()) | ||
| 54 | { | ||
| 55 | var baseFolder = fs.GetFolder(); | ||
| 56 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
| 57 | var binFolder = Path.Combine(baseFolder, "bin"); | ||
| 58 | var msiPath = Path.Combine(binFolder, "test.msi"); | ||
| 59 | |||
| 60 | var result = WixRunner.Execute(new[] | ||
| 61 | { | ||
| 62 | "build", | ||
| 63 | Path.Combine(folder, file), | ||
| 64 | "-intermediateFolder", intermediateFolder, | ||
| 65 | "-bindpath", folder, | ||
| 66 | "-o", msiPath, | ||
| 67 | }); | ||
| 68 | result.AssertSuccess(); | ||
| 69 | |||
| 70 | return Query.QueryDatabase(msiPath, new[] { "Property", "_SummaryInformation" }) | ||
| 71 | .Where(s => s.StartsWith("Property:ALLUSERS") || s.StartsWith("Property:MSIINSTALLPERUSER") || s.StartsWith("_SummaryInformation:WordCount")) | ||
| 72 | .OrderBy(s => s) | ||
| 73 | .ToArray(); | ||
| 74 | } | ||
| 75 | } | ||
| 76 | } | ||
| 77 | } | ||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/AllUsers/PerMachine.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/AllUsers/PerMachine.wxs new file mode 100644 index 00000000..3f19277b --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/AllUsers/PerMachine.wxs | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
| 2 | <Package Version="1" | ||
| 3 | Name="MsiPackage" | ||
| 4 | Manufacturer="Example Corporation" | ||
| 5 | UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a" | ||
| 6 | Scope="perMachine"> | ||
| 7 | <MajorUpgrade DowngradeErrorMessage="Downgrade not allowed" /> | ||
| 8 | |||
| 9 | <Feature Id="ProductFeature" Title="Feature title"> | ||
| 10 | <Component Directory="DesktopFolder"> | ||
| 11 | <File Source="PerUser.wxs" /> | ||
| 12 | </Component> | ||
| 13 | </Feature> | ||
| 14 | </Package> | ||
| 15 | </Wix> | ||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/AllUsers/PerUser.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/AllUsers/PerUser.wxs new file mode 100644 index 00000000..12ba9c59 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/AllUsers/PerUser.wxs | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
| 2 | <Package Version="1" | ||
| 3 | Name="MsiPackage" | ||
| 4 | Manufacturer="Example Corporation" | ||
| 5 | UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a" | ||
| 6 | Scope="perUser"> | ||
| 7 | <MajorUpgrade DowngradeErrorMessage="Downgrade not allowed" /> | ||
| 8 | |||
| 9 | <Feature Id="ProductFeature" Title="Feature title"> | ||
| 10 | <Component Directory="DesktopFolder"> | ||
| 11 | <File Source="PerUser.wxs" /> | ||
| 12 | </Component> | ||
| 13 | </Feature> | ||
| 14 | </Package> | ||
| 15 | </Wix> | ||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/AllUsers/PerUserOrMachine.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/AllUsers/PerUserOrMachine.wxs new file mode 100644 index 00000000..293cf1fa --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/AllUsers/PerUserOrMachine.wxs | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
| 2 | <Package Version="1" | ||
| 3 | Name="MsiPackage" | ||
| 4 | Manufacturer="Example Corporation" | ||
| 5 | UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a" | ||
| 6 | Scope="perUserOrMachine"> | ||
| 7 | <MajorUpgrade DowngradeErrorMessage="Downgrade not allowed" /> | ||
| 8 | |||
| 9 | <Feature Id="ProductFeature" Title="Feature title"> | ||
| 10 | <Component Directory="DesktopFolder"> | ||
| 11 | <File Source="PerUser.wxs" /> | ||
| 12 | </Component> | ||
| 13 | </Feature> | ||
| 14 | </Package> | ||
| 15 | </Wix> | ||
