diff --git a/src/api/wix/WixToolset.Data/ErrorMessages.cs b/src/api/wix/WixToolset.Data/ErrorMessages.cs index 77433e6d6..7cb0f4f9a 100644 --- a/src/api/wix/WixToolset.Data/ErrorMessages.cs +++ b/src/api/wix/WixToolset.Data/ErrorMessages.cs @@ -55,7 +55,7 @@ public static Message AdvertiseStateMustMatch(SourceLineNumber sourceLineNumbers 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 7541969b7..071030a2f 100644 --- a/src/wix/WixToolset.Core/Compiler.cs +++ b/src/wix/WixToolset.Core/Compiler.cs @@ -514,7 +514,7 @@ private void ParseAppIdElement(XElement node, string componentId, YesNoType adve { 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 000000000..7d7fe07ac --- /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 7160bf73a..945e2133e 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 000000000..25c0f1763 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/AppId/TopLevelAppId.wxs @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + +