diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2020-06-03 14:01:28 +1000 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2020-06-03 14:24:34 +1000 |
| commit | 6bb2c3d5a2082c377a31bffe1bbdb950b5e15781 (patch) | |
| tree | a68f4a40454748189198cd74f8fd285b14df1c80 /src | |
| parent | 874fb5fc3597d784a4e8ac07d735e3caa34417be (diff) | |
| download | wix-6bb2c3d5a2082c377a31bffe1bbdb950b5e15781.tar.gz wix-6bb2c3d5a2082c377a31bffe1bbdb950b5e15781.tar.bz2 wix-6bb2c3d5a2082c377a31bffe1bbdb950b5e15781.zip | |
Get the inner exception test working in the MSBuild test project.
Diffstat (limited to 'src')
5 files changed, 43 insertions, 53 deletions
diff --git a/src/WixToolset.BuildTasks/ToolsetTask.cs b/src/WixToolset.BuildTasks/ToolsetTask.cs index 94d007f0..ae11254a 100644 --- a/src/WixToolset.BuildTasks/ToolsetTask.cs +++ b/src/WixToolset.BuildTasks/ToolsetTask.cs | |||
| @@ -56,7 +56,19 @@ namespace WixToolset.BuildTasks | |||
| 56 | /// </summary> | 56 | /// </summary> |
| 57 | public bool VerboseOutput { get; set; } | 57 | public bool VerboseOutput { get; set; } |
| 58 | 58 | ||
| 59 | private string ToolFullPath => Path.Combine(Path.GetDirectoryName(ThisDllPath), this.ToolExe); | 59 | private string DefaultToolFullPath => Path.Combine(Path.GetDirectoryName(ThisDllPath), this.ToolExe); |
| 60 | |||
| 61 | private string ToolFullPath | ||
| 62 | { | ||
| 63 | get | ||
| 64 | { | ||
| 65 | if (String.IsNullOrEmpty(this.ToolPath)) | ||
| 66 | { | ||
| 67 | return this.DefaultToolFullPath; | ||
| 68 | } | ||
| 69 | return Path.Combine(this.ToolPath, this.ToolExe); | ||
| 70 | } | ||
| 71 | } | ||
| 60 | 72 | ||
| 61 | /// <summary> | 73 | /// <summary> |
| 62 | /// Get the path to the executable. | 74 | /// Get the path to the executable. |
| @@ -74,9 +86,9 @@ namespace WixToolset.BuildTasks | |||
| 74 | // We need to return a path that exists, so if we're not actually going to run the tool then just return this dll path. | 86 | // We need to return a path that exists, so if we're not actually going to run the tool then just return this dll path. |
| 75 | return ThisDllPath; | 87 | return ThisDllPath; |
| 76 | } | 88 | } |
| 77 | return this.ToolFullPath; | 89 | return this.DefaultToolFullPath; |
| 78 | #else | 90 | #else |
| 79 | if (IsSelfExecutable(this.ToolFullPath, out var toolFullPath)) | 91 | if (IsSelfExecutable(this.DefaultToolFullPath, out var toolFullPath)) |
| 80 | { | 92 | { |
| 81 | return toolFullPath; | 93 | return toolFullPath; |
| 82 | } | 94 | } |
diff --git a/src/test/WixToolsetTest.BuildTasks/WixBuildTaskFixture.cs b/src/test/WixToolsetTest.BuildTasks/WixBuildTaskFixture.cs index 92033766..cd41f16e 100644 --- a/src/test/WixToolsetTest.BuildTasks/WixBuildTaskFixture.cs +++ b/src/test/WixToolsetTest.BuildTasks/WixBuildTaskFixture.cs | |||
| @@ -62,48 +62,5 @@ namespace WixToolsetTest.BuildTasks | |||
| 62 | Assert.Equal(@"test.txt", fileTuple[FileTupleFields.Source].PreviousValue.AsPath().Path); | 62 | Assert.Equal(@"test.txt", fileTuple[FileTupleFields.Source].PreviousValue.AsPath().Path); |
| 63 | } | 63 | } |
| 64 | } | 64 | } |
| 65 | |||
| 66 | [Fact(Skip = "Requires deleting wixnative.exe from output folder after build but before running the test.")] | ||
| 67 | public void ReportsInnerExceptionForUnexpectedExceptions() | ||
| 68 | { | ||
| 69 | var folder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage"); | ||
| 70 | |||
| 71 | using (var fs = new DisposableFileSystem()) | ||
| 72 | { | ||
| 73 | var baseFolder = fs.GetFolder(); | ||
| 74 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
| 75 | var pdbPath = Path.Combine(baseFolder, @"bin\testpackage.wixpdb"); | ||
| 76 | var engine = new FakeBuildEngine(); | ||
| 77 | |||
| 78 | var task = new WixBuild | ||
| 79 | { | ||
| 80 | BuildEngine = engine, | ||
| 81 | SourceFiles = new[] | ||
| 82 | { | ||
| 83 | new TaskItem(Path.Combine(folder, "Package.wxs")), | ||
| 84 | new TaskItem(Path.Combine(folder, "PackageComponents.wxs")), | ||
| 85 | }, | ||
| 86 | LocalizationFiles = new[] | ||
| 87 | { | ||
| 88 | new TaskItem(Path.Combine(folder, "Package.en-us.wxl")), | ||
| 89 | }, | ||
| 90 | BindInputPaths = new[] | ||
| 91 | { | ||
| 92 | new TaskItem(Path.Combine(folder, "data")), | ||
| 93 | }, | ||
| 94 | IntermediateDirectory = new TaskItem(intermediateFolder), | ||
| 95 | OutputFile = new TaskItem(Path.Combine(baseFolder, @"bin\test.msi")), | ||
| 96 | PdbType = "Full", | ||
| 97 | PdbFile = new TaskItem(pdbPath), | ||
| 98 | }; | ||
| 99 | |||
| 100 | var result = task.Execute(); | ||
| 101 | Assert.False(result, $"MSBuild task succeeded unexpectedly. Output:\r\n{engine.Output}"); | ||
| 102 | |||
| 103 | Assert.Contains( | ||
| 104 | "System.PlatformNotSupportedException: Could not find platform specific 'wixnative.exe' ---> System.IO.FileNotFoundException: Could not find internal piece of WiX Toolset from", | ||
| 105 | engine.Output); | ||
| 106 | } | ||
| 107 | } | ||
| 108 | } | 65 | } |
| 109 | } | 66 | } |
diff --git a/src/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.csproj b/src/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.csproj index 22d421de..bfcc10ad 100644 --- a/src/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.csproj +++ b/src/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.csproj | |||
| @@ -17,12 +17,6 @@ | |||
| 17 | </ItemGroup> | 17 | </ItemGroup> |
| 18 | 18 | ||
| 19 | <ItemGroup> | 19 | <ItemGroup> |
| 20 | <Content Include="..\..\WixToolset.MSBuild\tools\wix.harvest.targets" Link="wix.harvest.targets" CopyToOutputDirectory="PreserveNewest" /> | ||
| 21 | <Content Include="..\..\WixToolset.MSBuild\tools\wix.signing.targets" Link="wix.signing.targets" CopyToOutputDirectory="PreserveNewest" /> | ||
| 22 | <Content Include="..\..\WixToolset.MSBuild\tools\wix.targets" Link="wix.targets" CopyToOutputDirectory="PreserveNewest" /> | ||
| 23 | </ItemGroup> | ||
| 24 | |||
| 25 | <ItemGroup> | ||
| 26 | <ProjectReference Include="..\..\WixToolset.BuildTasks\WixToolset.BuildTasks.csproj" /> | 20 | <ProjectReference Include="..\..\WixToolset.BuildTasks\WixToolset.BuildTasks.csproj" /> |
| 27 | </ItemGroup> | 21 | </ItemGroup> |
| 28 | 22 | ||
diff --git a/src/test/WixToolsetTest.MSBuild/MsbuildFixture.cs b/src/test/WixToolsetTest.MSBuild/MsbuildFixture.cs index 71255165..163e8402 100644 --- a/src/test/WixToolsetTest.MSBuild/MsbuildFixture.cs +++ b/src/test/WixToolsetTest.MSBuild/MsbuildFixture.cs | |||
| @@ -378,5 +378,31 @@ namespace WixToolsetTest.MSBuild | |||
| 378 | Assert.Empty(remainingPaths); | 378 | Assert.Empty(remainingPaths); |
| 379 | } | 379 | } |
| 380 | } | 380 | } |
| 381 | |||
| 382 | [Theory] | ||
| 383 | [InlineData(BuildSystem.DotNetCoreSdk)] | ||
| 384 | [InlineData(BuildSystem.MSBuild)] | ||
| 385 | [InlineData(BuildSystem.MSBuild64)] | ||
| 386 | public void ReportsInnerExceptionForUnexpectedExceptions(BuildSystem buildSystem) | ||
| 387 | { | ||
| 388 | var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage"); | ||
| 389 | |||
| 390 | using (var fs = new TestDataFolderFileSystem()) | ||
| 391 | { | ||
| 392 | fs.Initialize(sourceFolder); | ||
| 393 | var baseFolder = fs.BaseFolder; | ||
| 394 | var binFolder = Path.Combine(baseFolder, @"bin\"); | ||
| 395 | var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj"); | ||
| 396 | |||
| 397 | var result = MsbuildUtilities.BuildProject(buildSystem, projectPath, new[] | ||
| 398 | { | ||
| 399 | MsbuildUtilities.GetQuotedPropertySwitch(buildSystem, "WixToolDir", Path.Combine(MsbuildUtilities.WixMsbuildPath, "broken", "net461")), | ||
| 400 | }, outOfProc: true); | ||
| 401 | Assert.Equal(1, result.ExitCode); | ||
| 402 | |||
| 403 | var expectedMessage = "System.PlatformNotSupportedException: Could not find platform specific 'wixnative.exe' ---> System.IO.FileNotFoundException: Could not find internal piece of WiX Toolset from"; | ||
| 404 | Assert.Contains(result.Output, m => m.Contains(expectedMessage)); | ||
| 405 | } | ||
| 406 | } | ||
| 381 | } | 407 | } |
| 382 | } | 408 | } |
diff --git a/src/test/WixToolsetTest.MSBuild/MsbuildUtilities.cs b/src/test/WixToolsetTest.MSBuild/MsbuildUtilities.cs index 90c3194b..fead4915 100644 --- a/src/test/WixToolsetTest.MSBuild/MsbuildUtilities.cs +++ b/src/test/WixToolsetTest.MSBuild/MsbuildUtilities.cs | |||
| @@ -17,7 +17,8 @@ namespace WixToolsetTest.MSBuild | |||
| 17 | 17 | ||
| 18 | public static class MsbuildUtilities | 18 | public static class MsbuildUtilities |
| 19 | { | 19 | { |
| 20 | public static readonly string WixPropsPath = Path.Combine(new Uri(typeof(MsbuildUtilities).Assembly.CodeBase).AbsolutePath, "..", "..", "publish", "WixToolset.MSBuild", "build", "WixToolset.MSBuild.props"); | 20 | public static readonly string WixMsbuildPath = Path.Combine(new Uri(typeof(MsbuildUtilities).Assembly.CodeBase).AbsolutePath, "..", "..", "publish", "WixToolset.MSBuild"); |
| 21 | public static readonly string WixPropsPath = Path.Combine(WixMsbuildPath, "build", "WixToolset.MSBuild.props"); | ||
| 21 | 22 | ||
| 22 | public static MsbuildRunnerResult BuildProject(BuildSystem buildSystem, string projectPath, string[] arguments = null, string configuration = "Release", bool? outOfProc = null, string verbosityLevel = "normal") | 23 | public static MsbuildRunnerResult BuildProject(BuildSystem buildSystem, string projectPath, string[] arguments = null, string configuration = "Release", bool? outOfProc = null, string verbosityLevel = "normal") |
| 23 | { | 24 | { |
