Skip to content

Commit 5941d57

Browse files
committed
Add support for perMachineOrUser
Resolves 9175
1 parent 2b709cb commit 5941d57

File tree

6 files changed

+52
-4
lines changed

6 files changed

+52
-4
lines changed

src/api/wix/WixToolset.Data/Symbols/WixPackageSymbol.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public enum WixPackageScope
5454
PerMachine,
5555
PerUser,
5656
PerUserOrMachine,
57+
PerMachineOrUser,
5758
}
5859

5960
public enum WixPackageUpgradeStrategy

src/wix/WixToolset.Core.WindowsInstaller/Decompile/Decompiler.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3056,9 +3056,16 @@ private void FinalizeSummaryInformationStream(TableIndexedCollection tables)
30563056
{
30573057
xAllUsers?.Remove();
30583058
}
3059-
else if (xAllUsers?.Attribute("Value")?.Value == "2" && xMsiInstallerPerUser?.Attribute("Value")?.Value == "1")
3059+
else if (xAllUsers?.Attribute("Value")?.Value == "2")
30603060
{
3061-
this.DecompilerHelper.RootElement.SetAttributeValue("Scope", "perUserOrMachine");
3061+
if (xMsiInstallerPerUser?.Attribute("Value")?.Value == "1")
3062+
{
3063+
this.DecompilerHelper.RootElement.SetAttributeValue("Scope", "perUserOrMachine");
3064+
}
3065+
else
3066+
{
3067+
this.DecompilerHelper.RootElement.SetAttributeValue("Scope", "perMachineOrUser");
3068+
}
30623069

30633070
xAllUsers?.Remove();
30643071
xMsiInstallerPerUser?.Remove();

src/wix/WixToolset.Core/Compiler_Package.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ private void ParsePackageElement(XElement node)
9393
case "perMachine":
9494
// handled below after we create the section.
9595
break;
96+
case "perMachineOrUser":
97+
scope = WixPackageScope.PerMachineOrUser;
98+
break;
9699
case "perUser":
97100
scope = WixPackageScope.PerUser;
98101
sourceBits |= 8;
@@ -101,7 +104,7 @@ private void ParsePackageElement(XElement node)
101104
scope = WixPackageScope.PerUserOrMachine;
102105
break;
103106
default:
104-
this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, installScope, "perMachine", "perUser", "perUserOrMachine"));
107+
this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, installScope, "perMachine", "perMachineOrUser", "perUser", "perUserOrMachine"));
105108
break;
106109
}
107110
break;
@@ -210,6 +213,10 @@ private void ParsePackageElement(XElement node)
210213
this.AddProperty(sourceLineNumbers, new Identifier(AccessModifier.Global, "ALLUSERS"), "2", false, false, false, false);
211214
this.AddProperty(sourceLineNumbers, new Identifier(AccessModifier.Global, "MSIINSTALLPERUSER"), "1", false, false, false, false);
212215
}
216+
else if (scope == WixPackageScope.PerMachineOrUser)
217+
{
218+
this.AddProperty(sourceLineNumbers, new Identifier(AccessModifier.Global, "ALLUSERS"), "2", false, false, false, false);
219+
}
213220
else if (scope == WixPackageScope.PerMachine)
214221
{
215222
this.AddProperty(sourceLineNumbers, new Identifier(AccessModifier.Global, "ALLUSERS"), "1", false, false, false, false);

src/wix/test/WixToolsetTest.CoreIntegration/AllUsersFixture.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ public void CanCheckPerMachineMsi()
2222
}, propertyRows);
2323
}
2424

25+
[Fact]
26+
public void CanCheckPerMachineOrUserMsi()
27+
{
28+
var propertyRows = BuildAndQueryPropertyTable("PerMachineOrUser.wxs");
29+
30+
WixAssert.CompareLineByLine(new[]
31+
{
32+
"_SummaryInformation:WordCount\t2",
33+
"Property:ALLUSERS\t2"
34+
}, propertyRows);
35+
}
36+
2537
[Fact]
2638
public void CanCheckPerUserMsi()
2739
{
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2+
<Package Id="WixToolsetTest.TestPackage"
3+
Version="1"
4+
Name="PerMachine Or User Msi"
5+
Manufacturer="Example Corporation"
6+
Scope="perMachineOrUser">
7+
8+
<File Source="PerMachineOrUser.wxs" />
9+
</Package>
10+
</Wix>

src/xsd/wix.xsd

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14187,6 +14187,16 @@
1418714187
</xs:documentation>
1418814188
</xs:annotation>
1418914189
</xs:enumeration>
14190+
<xs:enumeration value="perMachineOrUser">
14191+
<xs:annotation>
14192+
<xs:documentation>
14193+
_New in WiX v7: WiX v7 adds this option to the Package Scope attribute._
14194+
Set this value to declare that the package is [dual-purpose that can install per-machine or per-user](https://learn.microsoft.com/en-us/windows/win32/msi/single-package-authoring)
14195+
and defaults to installing per-machine.
14196+
Sets the ALLUSERS property to 2.
14197+
</xs:documentation>
14198+
</xs:annotation>
14199+
</xs:enumeration>
1419014200
<xs:enumeration value="perUser">
1419114201
<xs:annotation>
1419214202
<xs:documentation>
@@ -14198,7 +14208,8 @@
1419814208
<xs:enumeration value="perUserOrMachine">
1419914209
<xs:annotation>
1420014210
<xs:documentation>
14201-
Set this value to declare that the package is [dual-purpose that can install per-user or per-machine](https://learn.microsoft.com/en-us/windows/win32/msi/single-package-authoring).
14211+
Set this value to declare that the package is [dual-purpose that can install per-user or per-machine](https://learn.microsoft.com/en-us/windows/win32/msi/single-package-authoring)
14212+
and defaults to installing per-user.
1420214213
Sets the ALLUSERS property to 2 and MSIINSTALLPERUSER property to 1.
1420314214
</xs:documentation>
1420414215
</xs:annotation>

0 commit comments

Comments
 (0)