@joebigelow / wix / commits / 6bb2c3d5

Get the inner exception test working in the MSBuild test project.

Sean Hall committed Jun 3, 2020 at 14:01 UTC 6bb2c3d5a2082c377a31bffe1bbdb950b5e15781
6 files changed +44 -53
appveyor.cmd
+1
@@ -23,6 +23,7 @@ dotnet publish -c %_C% -o %_P%\WixToolset.MSBuild\tools\netcoreapp2.1\ -f netcor
23 dotnet publish -c %_C% -o %_P%\WixToolset.MSBuild\tools\netcoreapp2.1\ -f netcoreapp2.1 src\wix
24 dotnet publish -c %_C% -o %_P%\WixToolset.MSBuild\tools\netcoreapp2.1\ -f netcoreapp2.1 src\wixcop
25 dotnet publish -c %_C% -o %_P%\WixToolset.MSBuild\ src\WixToolset.MSBuild
26 +dotnet publish -c %_C% -o %_P%\WixToolset.MSBuild\broken\net461\ -f net461 -r dne src\wix
27
28 dotnet pack -c %_C% src\dotnet-wix
29 dotnet pack -c %_C% src\WixToolset.MSBuild
src/WixToolset.BuildTasks/ToolsetTask.cs
+15 -3
@@ -56,7 +56,19 @@ namespace WixToolset.BuildTasks
56 /// </summary>
57 public bool VerboseOutput { get; set; }
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 + }
72
73 /// <summary>
74 /// Get the path to the executable.
@@ -74,9 +86,9 @@ namespace WixToolset.BuildTasks
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.
87 return ThisDllPath;
88 }
77 - return this.ToolFullPath;
89 + return this.DefaultToolFullPath;
90 #else
79 - if (IsSelfExecutable(this.ToolFullPath, out var toolFullPath))
91 + if (IsSelfExecutable(this.DefaultToolFullPath, out var toolFullPath))
92 {
93 return toolFullPath;
94 }
src/test/WixToolsetTest.BuildTasks/WixBuildTaskFixture.cs
-43
@@ -62,48 +62,5 @@ namespace WixToolsetTest.BuildTasks
62 Assert.Equal(@"test.txt", fileTuple[FileTupleFields.Source].PreviousValue.AsPath().Path);
63 }
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 - }
65 }
66 }
src/test/WixToolsetTest.BuildTasks/WixToolsetTest.BuildTasks.csproj
-6
@@ -16,12 +16,6 @@
16 <Content Include="..\WixToolsetTest.MSBuild\TestData\SimpleMsiPackage\MsiPackage\data\test.txt" Link="TestData\SimpleMsiPackage\MsiPackage\data\test.txt" CopyToOutputDirectory="PreserveNewest" />
17 </ItemGroup>
18
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 -
19 <ItemGroup>
20 <ProjectReference Include="..\..\WixToolset.BuildTasks\WixToolset.BuildTasks.csproj" />
21 </ItemGroup>
src/test/WixToolsetTest.MSBuild/MsbuildFixture.cs
+26
@@ -378,5 +378,31 @@ namespace WixToolsetTest.MSBuild
378 Assert.Empty(remainingPaths);
379 }
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 + }
407 }
408 }
src/test/WixToolsetTest.MSBuild/MsbuildUtilities.cs
+2 -1
@@ -17,7 +17,8 @@ namespace WixToolsetTest.MSBuild
17
18 public static class MsbuildUtilities
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");
22
23 public static MsbuildRunnerResult BuildProject(BuildSystem buildSystem, string projectPath, string[] arguments = null, string configuration = "Release", bool? outOfProc = null, string verbosityLevel = "normal")
24 {