diff --git a/src/wix/WixToolset.Core/Compiler_Package.cs b/src/wix/WixToolset.Core/Compiler_Package.cs index 9c1b316aa..725f92f95 100644 --- a/src/wix/WixToolset.Core/Compiler_Package.cs +++ b/src/wix/WixToolset.Core/Compiler_Package.cs @@ -28,6 +28,7 @@ private void ParsePackageElement(XElement node) var compressed = YesNoDefaultType.Default; var sourceBits = 0; string codepage = null; + string comments = null; var productCode = "*"; string productLanguage = null; var isPerMachine = true; @@ -55,6 +56,9 @@ private void ParsePackageElement(XElement node) case "Codepage": codepage = this.Core.GetAttributeLocalizableCodePageValue(sourceLineNumbers, attrib); break; + case "Comments": + comments = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; case "Compressed": compressed = this.Core.GetAttributeYesNoDefaultValue(sourceLineNumbers, attrib); break; @@ -193,7 +197,7 @@ private void ParsePackageElement(XElement node) this.Core.AddSymbol(new SummaryInformationSymbol(sourceLineNumbers) { PropertyId = SummaryInformationType.Comments, - Value = String.Format(CultureInfo.InvariantCulture, "This installer database contains the logic and data required to install {0}.", this.activeName) + Value = comments ?? String.Format(CultureInfo.InvariantCulture, "This installer database contains the logic and data required to install {0}.", this.activeName) }); this.ValidateAndAddCommonSummaryInformationSymbols(sourceLineNumbers, msiVersion, platform, productLanguage); diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/CommentsFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/CommentsFixture.cs new file mode 100644 index 000000000..d38d3a7e8 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/CommentsFixture.cs @@ -0,0 +1,75 @@ +// 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 System.Linq; + using WixInternal.Core.TestPackage; + using WixInternal.TestSupport; + using WixToolset.Data; + using Xunit; + + public class CommentsFixture + { + [Fact] + public void DefaultComments() + { + var propertyRows = BuildAndQuerySummaryInformation("Default.wxs"); + + WixAssert.CompareLineByLine(new[] + { + "_SummaryInformation:Comments\tThis installer database contains the logic and data required to install MsiPackage." + }, propertyRows); + } + + [Fact] + public void EmptyCommentsThrows() + { + var exception = Assert.Throws(() => BuildAndQuerySummaryInformation("Empty.wxs")); + WixAssert.StringEqual("The Package/@Comments attribute's value cannot be an empty string. If a value is not required, simply remove the entire attribute.", exception.Message); + } + + [Fact] + public void CustomComments() + { + var propertyRows = BuildAndQuerySummaryInformation("Custom.wxs"); + + WixAssert.CompareLineByLine(new[] + { + "_SummaryInformation:Comments\tExample comments" + }, propertyRows); + } + + private static string[] BuildAndQuerySummaryInformation(string file) + { + var folder = TestData.Get("TestData", "Comments"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + var binFolder = Path.Combine(baseFolder, "bin"); + var msiPath = Path.Combine(binFolder, "test.msi"); + + var result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, file), + "-intermediateFolder", intermediateFolder, + "-bindpath", folder, + "-o", msiPath, + }); + + if(result.ExitCode != 0) + { + throw new WixException(result.Messages.First()); + } + + return Query.QueryDatabase(msiPath, new[] { "Property", "_SummaryInformation" }) + .Where(s => s.StartsWith("_SummaryInformation:Comments")) + .OrderBy(s => s) + .ToArray(); + } + } + } +} diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Comments/Custom.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Comments/Custom.wxs new file mode 100644 index 000000000..f6e8361cb --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Comments/Custom.wxs @@ -0,0 +1,9 @@ + + + + + diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Comments/Default.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Comments/Default.wxs new file mode 100644 index 000000000..f2337b391 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Comments/Default.wxs @@ -0,0 +1,8 @@ + + + + + diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Comments/Empty.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Comments/Empty.wxs new file mode 100644 index 000000000..f1400efed --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Comments/Empty.wxs @@ -0,0 +1,9 @@ + + + + +