diff options
| author | Rob Mensching <rob@firegiant.com> | 2023-04-03 16:32:29 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2023-04-03 21:08:45 -0700 |
| commit | 9023fd4d6dd4339003defcfb12002432357193b9 (patch) | |
| tree | 7ab3630cb8cd5315ced63da0b293e35c5ce10002 /src | |
| parent | af72e6fdc0b2ba81bdacf2a460faf01c24b1e220 (diff) | |
| download | wix-9023fd4d6dd4339003defcfb12002432357193b9.tar.gz wix-9023fd4d6dd4339003defcfb12002432357193b9.tar.bz2 wix-9023fd4d6dd4339003defcfb12002432357193b9.zip | |
Handle error case when payload is missing both Name and SourceFile
Fixes 7333 and 7347
Diffstat (limited to 'src')
4 files changed, 90 insertions, 0 deletions
diff --git a/src/wix/WixToolset.Core/Compile/CompilerPayload.cs b/src/wix/WixToolset.Core/Compile/CompilerPayload.cs index e3dfc342..40205f19 100644 --- a/src/wix/WixToolset.Core/Compile/CompilerPayload.cs +++ b/src/wix/WixToolset.Core/Compile/CompilerPayload.cs | |||
| @@ -207,6 +207,11 @@ namespace WixToolset.Core | |||
| 207 | this.DownloadUrl = null; | 207 | this.DownloadUrl = null; |
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | if (String.IsNullOrEmpty(this.Name) && String.IsNullOrEmpty(this.SourceFile)) | ||
| 211 | { | ||
| 212 | this.Core.Write(ErrorMessages.ExpectedAttributes(this.SourceLineNumbers, this.Element.Name.LocalName, "Name", "SourceFile")); | ||
| 213 | } | ||
| 214 | |||
| 210 | if (!this.Core.EncounteredError) | 215 | if (!this.Core.EncounteredError) |
| 211 | { | 216 | { |
| 212 | symbol = this.Core.AddSymbol(new WixBundlePayloadSymbol(this.SourceLineNumbers, this.Id) | 217 | symbol = this.Core.AddSymbol(new WixBundlePayloadSymbol(this.SourceLineNumbers, this.Id) |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/BundleFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/BundleFixture.cs index 2cc7a681..5c51ecdb 100644 --- a/src/wix/test/WixToolsetTest.CoreIntegration/BundleFixture.cs +++ b/src/wix/test/WixToolsetTest.CoreIntegration/BundleFixture.cs | |||
| @@ -406,6 +406,60 @@ namespace WixToolsetTest.CoreIntegration | |||
| 406 | } | 406 | } |
| 407 | 407 | ||
| 408 | [Fact] | 408 | [Fact] |
| 409 | public void CannotBuildBundleMissingMsiSource() | ||
| 410 | { | ||
| 411 | var folder = TestData.Get(@"TestData"); | ||
| 412 | |||
| 413 | using (var fs = new DisposableFileSystem()) | ||
| 414 | { | ||
| 415 | var baseFolder = fs.GetFolder(); | ||
| 416 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
| 417 | |||
| 418 | var result = WixRunner.Execute(new[] | ||
| 419 | { | ||
| 420 | "build", | ||
| 421 | Path.Combine(folder, "BundleWithMissingSource", "BundleMissingMsiSource.wxs"), | ||
| 422 | "-bindpath", Path.Combine(folder, ".Data"), | ||
| 423 | "-intermediateFolder", intermediateFolder, | ||
| 424 | "-o", Path.Combine(baseFolder, @"bin\test.exe") | ||
| 425 | }); | ||
| 426 | |||
| 427 | var message = result.Messages.Where(m => m.Level == MessageLevel.Error).Select(m => m.ToString().Replace(folder, "<testdata>")).ToArray(); | ||
| 428 | WixAssert.CompareLineByLine(new[] | ||
| 429 | { | ||
| 430 | @"The MsiPackage element's Name or SourceFile attribute was not found; one of these is required." | ||
| 431 | }, message); | ||
| 432 | } | ||
| 433 | } | ||
| 434 | |||
| 435 | [Fact] | ||
| 436 | public void CannotBuildBundleMissingMsuSource() | ||
| 437 | { | ||
| 438 | var folder = TestData.Get(@"TestData"); | ||
| 439 | |||
| 440 | using (var fs = new DisposableFileSystem()) | ||
| 441 | { | ||
| 442 | var baseFolder = fs.GetFolder(); | ||
| 443 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
| 444 | |||
| 445 | var result = WixRunner.Execute(new[] | ||
| 446 | { | ||
| 447 | "build", | ||
| 448 | Path.Combine(folder, "BundleWithMissingSource", "BundleMissingMsuSource.wxs"), | ||
| 449 | "-bindpath", Path.Combine(folder, ".Data"), | ||
| 450 | "-intermediateFolder", intermediateFolder, | ||
| 451 | "-o", Path.Combine(baseFolder, @"bin\test.exe") | ||
| 452 | }); | ||
| 453 | |||
| 454 | var message = result.Messages.Where(m => m.Level == MessageLevel.Error).Select(m => m.ToString().Replace(folder, "<testdata>")).ToArray(); | ||
| 455 | WixAssert.CompareLineByLine(new[] | ||
| 456 | { | ||
| 457 | @"The MsuPackage element's Name or SourceFile attribute was not found; one of these is required." | ||
| 458 | }, message); | ||
| 459 | } | ||
| 460 | } | ||
| 461 | |||
| 462 | [Fact] | ||
| 409 | public void CannotBuildBundleWithInvalidIcon() | 463 | public void CannotBuildBundleWithInvalidIcon() |
| 410 | { | 464 | { |
| 411 | var folder = TestData.Get(@"TestData"); | 465 | var folder = TestData.Get(@"TestData"); |
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithMissingSource/BundleMissingMsiSource.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithMissingSource/BundleMissingMsiSource.wxs new file mode 100644 index 00000000..b2141a70 --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithMissingSource/BundleMissingMsiSource.wxs | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
| 2 | <Bundle Name="BundleMissingMsiSource" | ||
| 3 | Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="B94478B1-E1F3-4700-9CE8-6AA090854AEC"> | ||
| 4 | <BootstrapperApplication> | ||
| 5 | <BootstrapperApplicationDll SourceFile="fakeba.dll" /> | ||
| 6 | </BootstrapperApplication> | ||
| 7 | |||
| 8 | <Chain> | ||
| 9 | <MsiPackage | ||
| 10 | Id="MsiPackage1" | ||
| 11 | DisplayName="Msi Package #1" | ||
| 12 | DownloadUrl="http://example.com/test.msi" /> | ||
| 13 | </Chain> | ||
| 14 | </Bundle> | ||
| 15 | </Wix> | ||
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithMissingSource/BundleMissingMsuSource.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithMissingSource/BundleMissingMsuSource.wxs new file mode 100644 index 00000000..1e2d0e6c --- /dev/null +++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/BundleWithMissingSource/BundleMissingMsuSource.wxs | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> | ||
| 2 | <Bundle Name="BundleMissingMsuSource" | ||
| 3 | Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="B94478B1-E1F3-4700-9CE8-6AA090854AEC"> | ||
| 4 | <BootstrapperApplication> | ||
| 5 | <BootstrapperApplicationDll SourceFile="fakeba.dll" /> | ||
| 6 | </BootstrapperApplication> | ||
| 7 | |||
| 8 | <Chain> | ||
| 9 | <MsuPackage | ||
| 10 | Id="MsuPackage1" | ||
| 11 | DetectCondition="TODO" | ||
| 12 | DisplayName="MSU Package #1" | ||
| 13 | DownloadUrl="http://example.com/test.msu" /> | ||
| 14 | </Chain> | ||
| 15 | </Bundle> | ||
| 16 | </Wix> | ||
