From 6b7ad550ab4caaa262137539c9e5b0017fba4bd5 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 10 Aug 2022 12:58:21 -0700 Subject: Improve error messages for remote payloads --- src/ext/NetFx/wixlib/NetCoreShared.wxs | 1 - src/wix/WixToolset.Core/Compile/CompilerPayload.cs | 8 +++--- .../ExePackageFixture.cs | 30 ++++++++++++++++++++++ .../ExePackageWithoutSourceHashOrCertificate.wxs | 13 ++++++++++ 4 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 src/wix/test/WixToolsetTest.CoreIntegration/TestData/ExePackage/ExePackageWithoutSourceHashOrCertificate.wxs (limited to 'src') diff --git a/src/ext/NetFx/wixlib/NetCoreShared.wxs b/src/ext/NetFx/wixlib/NetCoreShared.wxs index 0332041a..2045a5b9 100644 --- a/src/ext/NetFx/wixlib/NetCoreShared.wxs +++ b/src/ext/NetFx/wixlib/NetCoreShared.wxs @@ -1,6 +1,5 @@  - diff --git a/src/wix/WixToolset.Core/Compile/CompilerPayload.cs b/src/wix/WixToolset.Core/Compile/CompilerPayload.cs index a83f1d8b..e3dfc342 100644 --- a/src/wix/WixToolset.Core/Compile/CompilerPayload.cs +++ b/src/wix/WixToolset.Core/Compile/CompilerPayload.cs @@ -115,22 +115,22 @@ namespace WixToolset.Core if (!String.IsNullOrEmpty(this.Description)) { - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "Description", "SourceFile")); + this.Core.Write(ErrorMessages.IllegalAttributeWithoutOtherAttributes(this.SourceLineNumbers, this.Element.Name.LocalName, "Description", "Hash", "CertificatePublicKey")); } if (!String.IsNullOrEmpty(this.ProductName)) { - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "ProductName", "SourceFile")); + this.Core.Write(ErrorMessages.IllegalAttributeWithoutOtherAttributes(this.SourceLineNumbers, this.Element.Name.LocalName, "ProductName", "Hash", "CertificatePublicKey")); } if (this.Size.HasValue) { - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "Size", "SourceFile")); + this.Core.Write(ErrorMessages.IllegalAttributeWithoutOtherAttributes(this.SourceLineNumbers, this.Element.Name.LocalName, "Size", "Hash", "CertificatePublicKey")); } if (!String.IsNullOrEmpty(this.Version)) { - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "Version", "SourceFile")); + this.Core.Write(ErrorMessages.IllegalAttributeWithoutOtherAttributes(this.SourceLineNumbers, this.Element.Name.LocalName, "Version", "Hash", "CertificatePublicKey")); } } else diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/ExePackageFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/ExePackageFixture.cs index 647a5386..882a7861 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/ExePackageFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/ExePackageFixture.cs @@ -469,5 +469,35 @@ namespace WixToolsetTest.CoreIntegration Assert.Equal(10, result.ExitCode); } } + + [Fact] + public void CannotBuildBundleWithExePackageWithoutSourceOrHashOrCertificate() + { + var dotDatafolder = TestData.Get(@"TestData", ".Data"); + var folder = TestData.Get(@"TestData", "ExePackage"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + + var result = WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "ExePackageWithoutSourceHashOrCertificate.wxs"), + "-bindpath", Path.Combine(folder, "data"), + "-bindpath", dotDatafolder, + "-intermediateFolder", intermediateFolder, + "-o", Path.Combine(baseFolder, "bin", "test.exe") + }); + + WixAssert.CompareLineByLine(new[] + { + "The ExePackagePayload/@Description attribute can only be specified with one of the following attributes: Hash or CertificatePublicKey present.", + "The ExePackagePayload/@Size attribute can only be specified with one of the following attributes: Hash or CertificatePublicKey present.", + "The ExePackagePayload/@Version attribute can only be specified with one of the following attributes: Hash or CertificatePublicKey present.", + }, result.Messages.Select(m => m.ToString()).ToArray()); + } + } } } diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/ExePackage/ExePackageWithoutSourceHashOrCertificate.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/ExePackage/ExePackageWithoutSourceHashOrCertificate.wxs new file mode 100644 index 00000000..21ea3524 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/ExePackage/ExePackageWithoutSourceHashOrCertificate.wxs @@ -0,0 +1,13 @@ + + + + + + + + + + + + + -- cgit v1.2.3-55-g6feb