From 24082aafc87c9cc3ed22749e6b21d80e0d3e6ced Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Sun, 7 Mar 2021 17:37:56 -0500 Subject: Improve missing entry section error message. Fixes https://github.com/wixtoolset/issues/issues/5886 --- src/WixToolset.Core/Linker.cs | 9 ++- .../LinkerFixture.cs | 90 ++++++++++++++++++++++ 2 files changed, 98 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/WixToolset.Core/Linker.cs b/src/WixToolset.Core/Linker.cs index 3281cbd0..f5461bbc 100644 --- a/src/WixToolset.Core/Linker.cs +++ b/src/WixToolset.Core/Linker.cs @@ -106,7 +106,14 @@ namespace WixToolset.Core // Must have found the entry section by now. if (null == find.EntrySection) { - throw new WixException(ErrorMessages.MissingEntrySection(this.Context.ExpectedOutputType.ToString())); + if (this.Context.ExpectedOutputType == OutputType.IntermediatePostLink || this.Context.ExpectedOutputType == OutputType.Unknown) + { + throw new WixException(ErrorMessages.MissingEntrySection()); + } + else + { + throw new WixException(ErrorMessages.MissingEntrySection(this.Context.ExpectedOutputType.ToString())); + } } // Add the missing standard action and directory symbols. diff --git a/src/test/WixToolsetTest.CoreIntegration/LinkerFixture.cs b/src/test/WixToolsetTest.CoreIntegration/LinkerFixture.cs index d85eb3bf..41c1d773 100644 --- a/src/test/WixToolsetTest.CoreIntegration/LinkerFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/LinkerFixture.cs @@ -79,5 +79,95 @@ namespace WixToolsetTest.CoreIntegration //Assert.Equal(@"test.txt", wixFile[WixFileSymbolFields.Source].PreviousValue.AsPath().Path); } } + + [Fact] + public void MissingEntrySectionDetectedProduct() + { + var folder = TestData.Get(@"TestData\OverridableActions"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + + try + { + WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "PackageComponents.wxs"), + "-intermediateFolder", intermediateFolder, + "-o", Path.Combine(baseFolder, @"bin\test.msi") + }); + } + catch (WixException we) + { + Assert.Equal("Could not find entry section in provided list of intermediates. Expected section of type 'Product'.", we.Message); + return; + } + + Assert.True(false, "Expected WixException for missing entry section but expectations were not met."); + } + } + + [Fact] + public void MissingEntrySectionDetectedWixipl() + { + var folder = TestData.Get(@"TestData\OverridableActions"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + + try + { + WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "PackageComponents.wxs"), + "-intermediateFolder", intermediateFolder, + "-o", Path.Combine(baseFolder, @"bin\test.wixipl") + }); + } + catch (WixException we) + { + Assert.Equal("Could not find entry section in provided list of intermediates. Supported entry section types are: Product, Bundle, Patch, PatchCreation, Module.", we.Message); + return; + } + + Assert.True(false, "Expected WixException for missing entry section but expectations were not met."); + } + } + + [Fact] + public void MissingEntrySectionDetectedUnknown() + { + var folder = TestData.Get(@"TestData\OverridableActions"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + + try + { + WixRunner.Execute(new[] + { + "build", + Path.Combine(folder, "PackageComponents.wxs"), + "-intermediateFolder", intermediateFolder, + "-o", Path.Combine(baseFolder, @"bin\test.bob") + }); + } + catch (WixException we) + { + Assert.Equal("Could not find entry section in provided list of intermediates. Supported entry section types are: Product, Bundle, Patch, PatchCreation, Module.", we.Message); + return; + } + + Assert.True(false, "Expected WixException for missing entry section but expectations were not met."); + } + } } } -- cgit v1.2.3-55-g6feb