From 1e6697673d0d1bad77cbd6ef11ece45cf6aeac28 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Mon, 6 Nov 2023 22:36:57 -0800 Subject: Correctly handle top-level AppId element Fixes 7738 --- src/api/wix/WixToolset.Data/ErrorMessages.cs | 2 +- src/wix/WixToolset.Core/Compiler.cs | 2 +- .../WixToolsetTest.CoreIntegration/AppIdFixture.cs | 76 ++++++++++++++++++++++ .../MsiQueryFixture.cs | 33 ---------- .../TestData/AppId/TopLevelAppId.wxs | 19 ++++++ 5 files changed, 97 insertions(+), 35 deletions(-) create mode 100644 src/wix/test/WixToolsetTest.CoreIntegration/AppIdFixture.cs create mode 100644 src/wix/test/WixToolsetTest.CoreIntegration/TestData/AppId/TopLevelAppId.wxs 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 public static Message AppIdIncompatibleAdvertiseState(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string value, string parentValue) { - 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); + 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); } 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 { this.Core.Write(ErrorMessages.AppIdIncompatibleAdvertiseState(sourceLineNumbers, node.Name.LocalName, "Advertise", appIdAdvertise.ToString(), advertise.ToString())); } - else + else if (appIdAdvertise != YesNoType.NotSet) { advertise = appIdAdvertise; } 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 @@ +// 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. + +namespace WixToolsetTest.CoreIntegration +{ + using System.IO; + using WixInternal.Core.TestPackage; + using WixInternal.TestSupport; + using Xunit; + + public class AppIdFixture + { + [Fact] + public void PopulatesAppIdTableAtTopLevel() + { + var folder = TestData.Get(@"TestData"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + var msiPath = Path.Combine(baseFolder, @"bin", "test.msi"); + + var result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "AppId", "TopLevelAppId.wxs"), + "-bindpath", Path.Combine(folder, "SingleFile", "data"), + "-intermediateFolder", intermediateFolder, + "-o", msiPath + }); + + result.AssertSuccess(); + + Assert.True(File.Exists(msiPath)); + var results = Query.QueryDatabase(msiPath, new[] { "AppId" }); + WixAssert.CompareLineByLine(new[] + { + "AppId:{D6040299-B15C-4C94-AE26-0C9B60D14C35}\t\t\t\t\t\t", + }, results); + } + } + + [Fact] + public void PopulatesAppIdTableWhenAdvertised() + { + var folder = TestData.Get(@"TestData"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + var msiPath = Path.Combine(baseFolder, @"bin", "test.msi"); + + var result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "AppId", "Advertised.wxs"), + Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), + Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), + "-bindpath", Path.Combine(folder, "SingleFile", "data"), + "-intermediateFolder", intermediateFolder, + "-o", msiPath + }); + + result.AssertSuccess(); + + Assert.True(File.Exists(msiPath)); + var results = Query.QueryDatabase(msiPath, new[] { "AppId" }); + WixAssert.CompareLineByLine(new[] + { + "AppId:{D6040299-B15C-4C94-AE26-0C9B60D14C35}\t\t\t\t\t\t", + }, results); + } + } + } +} 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 @@ -12,39 +12,6 @@ namespace WixToolsetTest.CoreIntegration public class MsiQueryFixture { - [Fact] - public void PopulatesAppIdTableWhenAdvertised() - { - var folder = TestData.Get(@"TestData"); - - using (var fs = new DisposableFileSystem()) - { - var baseFolder = fs.GetFolder(); - var intermediateFolder = Path.Combine(baseFolder, "obj"); - var msiPath = Path.Combine(baseFolder, @"bin\test.msi"); - - var result = WixRunner.Execute(new[] - { - "build", - Path.Combine(folder, "AppId", "Advertised.wxs"), - Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"), - Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"), - "-bindpath", Path.Combine(folder, "SingleFile", "data"), - "-intermediateFolder", intermediateFolder, - "-o", msiPath - }); - - result.AssertSuccess(); - - Assert.True(File.Exists(msiPath)); - var results = Query.QueryDatabase(msiPath, new[] { "AppId" }); - WixAssert.CompareLineByLine(new[] - { - "AppId:{D6040299-B15C-4C94-AE26-0C9B60D14C35}\t\t\t\t\t\t", - }, results); - } - } - [Fact] public void PopulatesAppSearchTablesFromComponentSearch() { 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 @@ + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3-55-g6feb