diff options
author | Rob Mensching <rob@firegiant.com> | 2023-11-06 22:36:57 -0800 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2023-11-07 14:27:27 -0800 |
commit | 1e6697673d0d1bad77cbd6ef11ece45cf6aeac28 (patch) | |
tree | ad74d9667794520466b671c035e599c2403b4168 | |
parent | 2781774e3f67bad1bef68e6ed32ab301179de531 (diff) | |
download | wix-1e6697673d0d1bad77cbd6ef11ece45cf6aeac28.tar.gz wix-1e6697673d0d1bad77cbd6ef11ece45cf6aeac28.tar.bz2 wix-1e6697673d0d1bad77cbd6ef11ece45cf6aeac28.zip |
Correctly handle top-level AppId element
Fixes 7738
5 files changed, 97 insertions, 35 deletions
diff --git a/src/api/wix/WixToolset.Data/ErrorMessages.cs b/src/api/wix/WixToolset.Data/ErrorMessages.cs index 77433e6d..7cb0f4f9 100644 --- a/src/api/wix/WixToolset.Data/ErrorMessages.cs +++ b/src/api/wix/WixToolset.Data/ErrorMessages.cs | |||
@@ -55,7 +55,7 @@ namespace WixToolset.Data | |||
55 | 55 | ||
56 | public static Message AppIdIncompatibleAdvertiseState(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string value, string parentValue) | 56 | public static Message AppIdIncompatibleAdvertiseState(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string value, string parentValue) |
57 | { | 57 | { |
58 | return Message(sourceLineNumbers, Ids.AppIdIncompatibleAdvertiseState, "The {0}/@(1) attribute's value, '{2}' does not match the advertise state on its parent element: '{3}'. (Note: AppIds nested under Fragment, Module, or Product elements must be advertised.)", elementName, attributeName, value, parentValue); | 58 | return Message(sourceLineNumbers, Ids.AppIdIncompatibleAdvertiseState, "The {0}/@(1) attribute's value, '{2}' does not match the advertise state on its parent element: '{3}'. (Note: AppIds nested under Fragment, Module, or Package elements must be advertised.)", elementName, attributeName, value, parentValue); |
59 | } | 59 | } |
60 | 60 | ||
61 | public static Message BaselineRequired() | 61 | public static Message BaselineRequired() |
diff --git a/src/wix/WixToolset.Core/Compiler.cs b/src/wix/WixToolset.Core/Compiler.cs index 36fd35b2..6063d463 100644 --- a/src/wix/WixToolset.Core/Compiler.cs +++ b/src/wix/WixToolset.Core/Compiler.cs | |||
@@ -514,7 +514,7 @@ namespace WixToolset.Core | |||
514 | { | 514 | { |
515 | this.Core.Write(ErrorMessages.AppIdIncompatibleAdvertiseState(sourceLineNumbers, node.Name.LocalName, "Advertise", appIdAdvertise.ToString(), advertise.ToString())); | 515 | this.Core.Write(ErrorMessages.AppIdIncompatibleAdvertiseState(sourceLineNumbers, node.Name.LocalName, "Advertise", appIdAdvertise.ToString(), advertise.ToString())); |
516 | } | 516 | } |
517 | else | 517 | else if (appIdAdvertise != YesNoType.NotSet) |
518 | { | 518 | { |
519 | advertise = appIdAdvertise; | 519 | advertise = appIdAdvertise; |
520 | } | 520 | } |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/AppIdFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/AppIdFixture.cs new file mode 100644 index 00000000..7d7fe07a --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/AppIdFixture.cs | |||
@@ -0,0 +1,76 @@ | |||
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 WixInternal.Core.TestPackage; | ||
7 | using WixInternal.TestSupport; | ||
8 | using Xunit; | ||
9 | |||
10 | public class AppIdFixture | ||
11 | { | ||
12 | [Fact] | ||
13 | public void PopulatesAppIdTableAtTopLevel() | ||
14 | { | ||
15 | var folder = TestData.Get(@"TestData"); | ||
16 | |||
17 | using (var fs = new DisposableFileSystem()) | ||
18 | { | ||
19 | var baseFolder = fs.GetFolder(); | ||
20 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
21 | var msiPath = Path.Combine(baseFolder, @"bin", "test.msi"); | ||
22 | |||
23 | var result = WixRunner.Execute(new[] | ||
24 | { | ||
25 | "build", | ||
26 | Path.Combine(folder, "AppId", "TopLevelAppId.wxs"), | ||
27 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), | ||
28 | "-intermediateFolder", intermediateFolder, | ||
29 | "-o", msiPath | ||
30 | }); | ||
31 | |||
32 | result.AssertSuccess(); | ||
33 | |||
34 | Assert.True(File.Exists(msiPath)); | ||
35 | var results = Query.QueryDatabase(msiPath, new[] { "AppId" }); | ||
36 | WixAssert.CompareLineByLine(new[] | ||
37 | { | ||
38 | "AppId:{D6040299-B15C-4C94-AE26-0C9B60D14C35}\t\t\t\t\t\t", | ||
39 | }, results); | ||
40 | } | ||
41 | } | ||
42 | |||
43 | [Fact] | ||
44 | public void PopulatesAppIdTableWhenAdvertised() | ||
45 | { | ||
46 | var folder = TestData.Get(@"TestData"); | ||
47 | |||
48 | using (var fs = new DisposableFileSystem()) | ||
49 | { | ||
50 | var baseFolder = fs.GetFolder(); | ||
51 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
52 | var msiPath = Path.Combine(baseFolder, @"bin", "test.msi"); | ||
53 | |||
54 | var result = WixRunner.Execute(new[] | ||
55 | { | ||
56 | "build", | ||
57 | Path.Combine(folder, "AppId", "Advertised.wxs"), | ||
58 | Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), | ||
59 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), | ||
60 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), | ||
61 | "-intermediateFolder", intermediateFolder, | ||
62 | "-o", msiPath | ||
63 | }); | ||
64 | |||
65 | result.AssertSuccess(); | ||
66 | |||
67 | Assert.True(File.Exists(msiPath)); | ||
68 | var results = Query.QueryDatabase(msiPath, new[] { "AppId" }); | ||
69 | WixAssert.CompareLineByLine(new[] | ||
70 | { | ||
71 | "AppId:{D6040299-B15C-4C94-AE26-0C9B60D14C35}\t\t\t\t\t\t", | ||
72 | }, results); | ||
73 | } | ||
74 | } | ||
75 | } | ||
76 | } | ||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs index 7160bf73..945e2133 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs | |||
@@ -13,39 +13,6 @@ namespace WixToolsetTest.CoreIntegration | |||
13 | public class MsiQueryFixture | 13 | public class MsiQueryFixture |
14 | { | 14 | { |
15 | [Fact] | 15 | [Fact] |
16 | public void PopulatesAppIdTableWhenAdvertised() | ||
17 | { | ||
18 | var folder = TestData.Get(@"TestData"); | ||
19 | |||
20 | using (var fs = new DisposableFileSystem()) | ||
21 | { | ||
22 | var baseFolder = fs.GetFolder(); | ||
23 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
24 | var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); | ||
25 | |||
26 | var result = WixRunner.Execute(new[] | ||
27 | { | ||
28 | "build", | ||
29 | Path.Combine(folder, "AppId", "Advertised.wxs"), | ||
30 | Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), | ||
31 | Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), | ||
32 | "-bindpath", Path.Combine(folder, "SingleFile", "data"), | ||
33 | "-intermediateFolder", intermediateFolder, | ||
34 | "-o", msiPath | ||
35 | }); | ||
36 | |||
37 | result.AssertSuccess(); | ||
38 | |||
39 | Assert.True(File.Exists(msiPath)); | ||
40 | var results = Query.QueryDatabase(msiPath, new[] { "AppId" }); | ||
41 | WixAssert.CompareLineByLine(new[] | ||
42 | { | ||
43 | "AppId:{D6040299-B15C-4C94-AE26-0C9B60D14C35}\t\t\t\t\t\t", | ||
44 | }, results); | ||
45 | } | ||
46 | } | ||
47 | |||
48 | [Fact] | ||
49 | public void PopulatesAppSearchTablesFromComponentSearch() | 16 | public void PopulatesAppSearchTablesFromComponentSearch() |
50 | { | 17 | { |
51 | var folder = TestData.Get(@"TestData"); | 18 | var folder = TestData.Get(@"TestData"); |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/AppId/TopLevelAppId.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/AppId/TopLevelAppId.wxs new file mode 100644 index 00000000..25c0f176 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/AppId/TopLevelAppId.wxs | |||
@@ -0,0 +1,19 @@ | |||
1 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
2 | <Package Name="~AppId Top-Level" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="12E4699F-E774-4D05-8A01-5BDD41BBA127" Compressed="no"> | ||
3 | <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> | ||
4 | |||
5 | <AppId Id="D6040299-B15C-4C94-AE26-0C9B60D14C35" /> | ||
6 | |||
7 | <Feature Id="ProductFeature" Title="MsiPackageTitle"> | ||
8 | <Component Directory="INSTALLFOLDER"> | ||
9 | <File Source="test.txt" /> | ||
10 | </Component> | ||
11 | </Feature> | ||
12 | </Package> | ||
13 | |||
14 | <Fragment> | ||
15 | <StandardDirectory Id="ProgramFiles6432Folder"> | ||
16 | <Directory Id="INSTALLFOLDER" Name="MsiPackage" /> | ||
17 | </StandardDirectory> | ||
18 | </Fragment> | ||
19 | </Wix> | ||