@joebigelow / wix / commits / 6b7ad550

Improve error messages for remote payloads

Rob Mensching committed Aug 10, 2022 at 12:58 UTC 6b7ad550ab4caaa262137539c9e5b0017fba4bd5
4 files changed +47 -5
src/ext/NetFx/wixlib/NetCoreShared.wxs
-1
@@ -1,6 +1,5 @@
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 -
3 <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
4
5 <?foreach PLATFORM in x86;x64?>
src/wix/WixToolset.Core/Compile/CompilerPayload.cs
+4 -4
@@ -115,22 +115,22 @@ namespace WixToolset.Core
115
116 if (!String.IsNullOrEmpty(this.Description))
117 {
118 - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "Description", "SourceFile"));
118 + this.Core.Write(ErrorMessages.IllegalAttributeWithoutOtherAttributes(this.SourceLineNumbers, this.Element.Name.LocalName, "Description", "Hash", "CertificatePublicKey"));
119 }
120
121 if (!String.IsNullOrEmpty(this.ProductName))
122 {
123 - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "ProductName", "SourceFile"));
123 + this.Core.Write(ErrorMessages.IllegalAttributeWithoutOtherAttributes(this.SourceLineNumbers, this.Element.Name.LocalName, "ProductName", "Hash", "CertificatePublicKey"));
124 }
125
126 if (this.Size.HasValue)
127 {
128 - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "Size", "SourceFile"));
128 + this.Core.Write(ErrorMessages.IllegalAttributeWithoutOtherAttributes(this.SourceLineNumbers, this.Element.Name.LocalName, "Size", "Hash", "CertificatePublicKey"));
129 }
130
131 if (!String.IsNullOrEmpty(this.Version))
132 {
133 - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(this.SourceLineNumbers, this.Element.Name.LocalName, "Version", "SourceFile"));
133 + this.Core.Write(ErrorMessages.IllegalAttributeWithoutOtherAttributes(this.SourceLineNumbers, this.Element.Name.LocalName, "Version", "Hash", "CertificatePublicKey"));
134 }
135 }
136 else
src/wix/test/WixToolsetTest.CoreIntegration/ExePackageFixture.cs
+30
@@ -469,5 +469,35 @@ namespace WixToolsetTest.CoreIntegration
469 Assert.Equal(10, result.ExitCode);
470 }
471 }
472 +
473 + [Fact]
474 + public void CannotBuildBundleWithExePackageWithoutSourceOrHashOrCertificate()
475 + {
476 + var dotDatafolder = TestData.Get(@"TestData", ".Data");
477 + var folder = TestData.Get(@"TestData", "ExePackage");
478 +
479 + using (var fs = new DisposableFileSystem())
480 + {
481 + var baseFolder = fs.GetFolder();
482 + var intermediateFolder = Path.Combine(baseFolder, "obj");
483 +
484 + var result = WixRunner.Execute(new[]
485 + {
486 + "build",
487 + Path.Combine(folder, "ExePackageWithoutSourceHashOrCertificate.wxs"),
488 + "-bindpath", Path.Combine(folder, "data"),
489 + "-bindpath", dotDatafolder,
490 + "-intermediateFolder", intermediateFolder,
491 + "-o", Path.Combine(baseFolder, "bin", "test.exe")
492 + });
493 +
494 + WixAssert.CompareLineByLine(new[]
495 + {
496 + "The ExePackagePayload/@Description attribute can only be specified with one of the following attributes: Hash or CertificatePublicKey present.",
497 + "The ExePackagePayload/@Size attribute can only be specified with one of the following attributes: Hash or CertificatePublicKey present.",
498 + "The ExePackagePayload/@Version attribute can only be specified with one of the following attributes: Hash or CertificatePublicKey present.",
499 + }, result.Messages.Select(m => m.ToString()).ToArray());
500 + }
501 + }
502 }
503 }
src/wix/test/WixToolsetTest.CoreIntegration/TestData/ExePackage/ExePackageWithoutSourceHashOrCertificate.wxs new
+13
@@ -0,0 +1,13 @@
1 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 + <Bundle Name="BurnBundle" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="B94478B1-E1F3-4700-9CE8-6AA090854AEC">
3 + <BootstrapperApplication>
4 + <BootstrapperApplicationDll SourceFile="fakeba.dll" />
5 + </BootstrapperApplication>
6 +
7 + <Chain>
8 + <ExePackage DetectCondition="DetectedTheMsu" UninstallArguments="-uninstall">
9 + <ExePackagePayload Name='foo.exe' DownloadUrl='http://wixtoolset.org' Description='Some description' Size='10' Version="1.2" />
10 + </ExePackage>
11 + </Chain>
12 + </Bundle>
13 +</Wix>