From b1b1028efeaf1e0bb3b56c4006450a60ff8e699d Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 13 May 2020 14:50:54 +1000 Subject: Ensure inner exceptions from unexpected exceptions get logged. --- .../WixBuildTaskFixture.cs | 43 ++++++++++++++++++++++ src/wix/Program.cs | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/test/WixToolsetTest.BuildTasks/WixBuildTaskFixture.cs b/src/test/WixToolsetTest.BuildTasks/WixBuildTaskFixture.cs index d572a91a..aa44ba81 100644 --- a/src/test/WixToolsetTest.BuildTasks/WixBuildTaskFixture.cs +++ b/src/test/WixToolsetTest.BuildTasks/WixBuildTaskFixture.cs @@ -62,5 +62,48 @@ namespace WixToolsetTest.BuildTasks Assert.Equal(@"test.txt", fileTuple[FileTupleFields.Source].PreviousValue.AsPath().Path); } } + + [Fact(Skip = "Requires deleting wixnative.exe from output folder after build but before running the test.")] + public void ReportsInnerExceptionForUnexpectedExceptions() + { + var folder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage"); + + using (var fs = new DisposableFileSystem()) + { + var baseFolder = fs.GetFolder(); + var intermediateFolder = Path.Combine(baseFolder, "obj"); + var pdbPath = Path.Combine(baseFolder, @"bin\testpackage.wixpdb"); + var engine = new FakeBuildEngine(); + + var task = new DoIt + { + BuildEngine = engine, + SourceFiles = new[] + { + new TaskItem(Path.Combine(folder, "Package.wxs")), + new TaskItem(Path.Combine(folder, "PackageComponents.wxs")), + }, + LocalizationFiles = new[] + { + new TaskItem(Path.Combine(folder, "Package.en-us.wxl")), + }, + BindInputPaths = new[] + { + new TaskItem(Path.Combine(folder, "data")), + }, + IntermediateDirectory = new TaskItem(intermediateFolder), + OutputFile = new TaskItem(Path.Combine(baseFolder, @"bin\test.msi")), + PdbType = "Full", + PdbFile = new TaskItem(pdbPath), + }; + + var result = task.Execute(); + Assert.False(result, $"MSBuild task succeeded unexpectedly. Output:\r\n{engine.Output}"); + + Assert.Contains( + "System.PlatformNotSupportedException: Could not find platform specific 'wixnative.exe' ---> System.IO.FileNotFoundException: Could not find internal piece of WiX Toolset from", + engine.Output); + } + } } } diff --git a/src/wix/Program.cs b/src/wix/Program.cs index e2012ad2..7e302078 100644 --- a/src/wix/Program.cs +++ b/src/wix/Program.cs @@ -41,7 +41,7 @@ namespace WixToolset.Tools } catch (Exception e) { - listener.Write(ErrorMessages.UnexpectedException(e.Message, e.GetType().ToString(), e.StackTrace)); + listener.Write(ErrorMessages.UnexpectedException(e)); if (e is NullReferenceException || e is SEHException) { -- cgit v1.2.3-55-g6feb