@joebigelow / wix-1 / commits / a886df0a

Correctly handle top-level AppId element

Fixes 7738

Rob Mensching committed Nov 6, 2023 at 22:36 UTC a886df0a02f26a3fc30cf836a5a4cadbf4ab2bcd
5 files changed +97 -35
src/api/wix/WixToolset.Data/ErrorMessages.cs
+1 -1
@@ -55,7 +55,7 @@ namespace WixToolset.Data
55
56 public static Message AppIdIncompatibleAdvertiseState(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string value, string parentValue)
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 }
60
61 public static Message BaselineRequired()
src/wix/WixToolset.Core/Compiler.cs
+1 -1
@@ -514,7 +514,7 @@ namespace WixToolset.Core
514 {
515 this.Core.Write(ErrorMessages.AppIdIncompatibleAdvertiseState(sourceLineNumbers, node.Name.LocalName, "Advertise", appIdAdvertise.ToString(), advertise.ToString()));
516 }
517 - else
517 + else if (appIdAdvertise != YesNoType.NotSet)
518 {
519 advertise = appIdAdvertise;
520 }
src/wix/test/WixToolsetTest.CoreIntegration/AppIdFixture.cs new
+76
@@ -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 +}
src/wix/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs
-33
@@ -12,39 +12,6 @@ namespace WixToolsetTest.CoreIntegration
12
13 public class MsiQueryFixture
14 {
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 -
15 [Fact]
16 public void PopulatesAppSearchTablesFromComponentSearch()
17 {
src/wix/test/WixToolsetTest.CoreIntegration/TestData/AppId/TopLevelAppId.wxs new
+19
@@ -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>