From d57dad051e9c15919646fb9e4fb320003ba839da Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sat, 30 May 2020 18:55:35 +1000 Subject: Change MSBuild tests to use the default intermediate and output folders. --- src/test/WixToolsetTest.MSBuild/MsbuildFixture.cs | 137 +++++++++++---------- .../WixToolsetTest.MSBuild/MsbuildHeatFixture.cs | 30 ++--- 2 files changed, 89 insertions(+), 78 deletions(-) (limited to 'src') diff --git a/src/test/WixToolsetTest.MSBuild/MsbuildFixture.cs b/src/test/WixToolsetTest.MSBuild/MsbuildFixture.cs index 85f111a9..abb8673d 100644 --- a/src/test/WixToolsetTest.MSBuild/MsbuildFixture.cs +++ b/src/test/WixToolsetTest.MSBuild/MsbuildFixture.cs @@ -3,6 +3,7 @@ namespace WixToolsetTest.MSBuild { using System; + using System.Collections.Generic; using System.IO; using System.Linq; using WixBuildTools.TestSupport; @@ -15,19 +16,18 @@ namespace WixToolsetTest.MSBuild [Fact] public void CanBuildSimpleBundle() { - var projectPath = TestData.Get(@"TestData\SimpleMsiPackage\SimpleBundle\SimpleBundle.wixproj"); + var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage"); - using (var fs = new DisposableFileSystem()) + using (var fs = new TestDataFolderFileSystem()) { - var baseFolder = fs.GetFolder(); + fs.Initialize(sourceFolder); + var baseFolder = Path.Combine(fs.BaseFolder, "SimpleBundle"); var binFolder = Path.Combine(baseFolder, @"bin\"); - var intermediateFolder = Path.Combine(baseFolder, @"obj\"); + var projectPath = Path.Combine(baseFolder, "SimpleBundle.wixproj"); var result = MsbuildRunner.Execute(projectPath, new[] { $"-p:WixTargetsPath={WixTargetsPath}", - $"-p:IntermediateOutputPath={intermediateFolder}", - $"-p:OutputPath={binFolder}" }); result.AssertSuccess(); @@ -43,8 +43,8 @@ namespace WixToolsetTest.MSBuild .ToArray(); Assert.Equal(new[] { - @"bin\SimpleBundle.exe", - @"bin\SimpleBundle.wixpdb", + @"bin\x86\Debug\SimpleBundle.exe", + @"bin\x86\Debug\SimpleBundle.wixpdb", }, paths); } } @@ -52,19 +52,18 @@ namespace WixToolsetTest.MSBuild [Fact] public void CanBuildSimpleMsiPackage() { - var projectPath = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage\MsiPackage.wixproj"); + var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage"); - using (var fs = new DisposableFileSystem()) + using (var fs = new TestDataFolderFileSystem()) { - var baseFolder = fs.GetFolder(); + fs.Initialize(sourceFolder); + var baseFolder = fs.BaseFolder; var binFolder = Path.Combine(baseFolder, @"bin\"); - var intermediateFolder = Path.Combine(baseFolder, @"obj\"); + var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj"); var result = MsbuildRunner.Execute(projectPath, new[] { $"-p:WixTargetsPath={WixTargetsPath}", - $"-p:IntermediateOutputPath={intermediateFolder}", - $"-p:OutputPath={binFolder}" }); result.AssertSuccess(); @@ -80,9 +79,9 @@ namespace WixToolsetTest.MSBuild .ToArray(); Assert.Equal(new[] { - @"bin\en-US\cab1.cab", - @"bin\en-US\MsiPackage.msi", - @"bin\en-US\MsiPackage.wixpdb", + @"bin\x86\Debug\en-US\cab1.cab", + @"bin\x86\Debug\en-US\MsiPackage.msi", + @"bin\x86\Debug\en-US\MsiPackage.wixpdb", }, paths); } } @@ -92,9 +91,9 @@ namespace WixToolsetTest.MSBuild { var expectedOutputs = new[] { - @"bin\en-US\cab1.cab", - @"bin\en-US\MsiPackage.msi", - @"bin\en-US\MsiPackage.wixpdb", + @"bin\x86\Debug\en-US\cab1.cab", + @"bin\x86\Debug\en-US\MsiPackage.msi", + @"bin\x86\Debug\en-US\MsiPackage.wixpdb", }; this.AssertWixpdb(null, expectedOutputs); @@ -106,27 +105,26 @@ namespace WixToolsetTest.MSBuild { this.AssertWixpdb("NONE", new[] { - @"bin\en-US\cab1.cab", - @"bin\en-US\MsiPackage.msi", + @"bin\x86\Debug\en-US\cab1.cab", + @"bin\x86\Debug\en-US\MsiPackage.msi", }); } private void AssertWixpdb(string wixpdbType, string[] expectedOutputFiles) { - var projectPath = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage\MsiPackage.wixproj"); + var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage"); - using (var fs = new DisposableFileSystem()) + using (var fs = new TestDataFolderFileSystem()) { - var baseFolder = fs.GetFolder(); + fs.Initialize(sourceFolder); + var baseFolder = fs.BaseFolder; var binFolder = Path.Combine(baseFolder, @"bin\"); - var intermediateFolder = Path.Combine(baseFolder, @"obj\"); + var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj"); var result = MsbuildRunner.Execute(projectPath, new[] { wixpdbType == null ? String.Empty : $"-p:WixPdbType={wixpdbType}", $"-p:WixTargetsPath={WixTargetsPath}", - $"-p:IntermediateOutputPath={intermediateFolder}", - $"-p:OutputPath={binFolder}", }); result.AssertSuccess(); @@ -141,44 +139,53 @@ namespace WixToolsetTest.MSBuild [Fact] public void CanBuild64BitMsiPackage() { - var projectPath = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage\MsiPackage.wixproj"); + var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage"); - using (var fs = new DisposableFileSystem()) + using (var fs = new TestDataFolderFileSystem()) { - var baseFolder = fs.GetFolder(); + fs.Initialize(sourceFolder); + var baseFolder = fs.BaseFolder; var binFolder = Path.Combine(baseFolder, @"bin\"); - var intermediateFolder = Path.Combine(baseFolder, @"obj\"); + var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj"); var result = MsbuildRunner.Execute(projectPath, new[] { $"-p:WixTargetsPath={WixTargetsPath}", - $"-p:IntermediateOutputPath={intermediateFolder}", - $"-p:OutputPath={binFolder}", $"-p:InstallerPlatform=x64", }); result.AssertSuccess(); var platformSwitches = result.Output.Where(line => line.TrimStart().StartsWith("wix.exe build -platform x64")); Assert.Single(platformSwitches); + + var paths = Directory.EnumerateFiles(binFolder, @"*.*", SearchOption.AllDirectories) + .Select(s => s.Substring(baseFolder.Length + 1)) + .OrderBy(s => s) + .ToArray(); + Assert.Equal(new[] + { + @"bin\x86\Debug\en-US\cab1.cab", + @"bin\x86\Debug\en-US\MsiPackage.msi", + @"bin\x86\Debug\en-US\MsiPackage.wixpdb", + }, paths); } } [Fact(Skip = "Currently fails")] public void CanBuildSimpleMsiPackageWithIceSuppressions() { - var projectPath = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage\MsiPackage.wixproj"); + var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage"); - using (var fs = new DisposableFileSystem()) + using (var fs = new TestDataFolderFileSystem()) { - var baseFolder = fs.GetFolder(); + fs.Initialize(sourceFolder); + var baseFolder = fs.BaseFolder; var binFolder = Path.Combine(baseFolder, @"bin\"); - var intermediateFolder = Path.Combine(baseFolder, @"obj\"); + var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj"); var result = MsbuildRunner.Execute(projectPath, new[] { $"-p:WixTargetsPath={WixTargetsPath}", - $"-p:IntermediateOutputPath={intermediateFolder}", - $"-p:OutputPath={binFolder}", "-p:SuppressIces=\"ICE45;ICE46\"" }); result.AssertSuccess(); @@ -188,19 +195,18 @@ namespace WixToolsetTest.MSBuild [Fact] public void CanBuildSimpleMsiPackageWithWarningSuppressions() { - var projectPath = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage\MsiPackage.wixproj"); + var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage"); - using (var fs = new DisposableFileSystem()) + using (var fs = new TestDataFolderFileSystem()) { - var baseFolder = fs.GetFolder(); + fs.Initialize(sourceFolder); + var baseFolder = fs.BaseFolder; var binFolder = Path.Combine(baseFolder, @"bin\"); - var intermediateFolder = Path.Combine(baseFolder, @"obj\"); + var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj"); var result = MsbuildRunner.Execute(projectPath, new[] { $"-p:WixTargetsPath={WixTargetsPath}", - $"-p:IntermediateOutputPath={intermediateFolder}", - $"-p:OutputPath={binFolder}", "-p:SuppressSpecificWarnings=\"1118;1102\"" }); result.AssertSuccess(); @@ -213,19 +219,18 @@ namespace WixToolsetTest.MSBuild [Fact] public void CanBuildSimpleMsiPackageAsWixipl() { - var projectPath = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage\MsiPackage.wixproj"); + var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage"); - using (var fs = new DisposableFileSystem()) + using (var fs = new TestDataFolderFileSystem()) { - var baseFolder = fs.GetFolder(); + fs.Initialize(sourceFolder); + var baseFolder = fs.BaseFolder; var binFolder = Path.Combine(baseFolder, @"bin\"); - var intermediateFolder = Path.Combine(baseFolder, @"obj\"); + var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj"); var result = MsbuildRunner.Execute(projectPath, new[] { $"-p:WixTargetsPath={WixTargetsPath}", - $"-p:IntermediateOutputPath={intermediateFolder}", - $"-p:OutputPath={binFolder}", "-p:OutputType=IntermediatePostLink" }); result.AssertSuccess(); @@ -233,27 +238,25 @@ namespace WixToolsetTest.MSBuild var path = Directory.EnumerateFiles(binFolder, @"*.*", SearchOption.AllDirectories) .Select(s => s.Substring(baseFolder.Length + 1)) .Single(); - Assert.Equal(@"bin\MsiPackage.wixipl", path); + Assert.Equal(@"bin\x86\Debug\MsiPackage.wixipl", path); } } [Fact] public void CanBuildAndCleanSimpleMsiPackage() { - var projectPath = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage\MsiPackage.wixproj"); + var sourceFolder = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage"); - using (var fs = new DisposableFileSystem()) + using (var fs = new TestDataFolderFileSystem()) { - var baseFolder = fs.GetFolder(); - var binFolder = Path.Combine(baseFolder, @"bin\"); - var intermediateFolder = Path.Combine(baseFolder, @"obj\"); + fs.Initialize(sourceFolder); + var baseFolder = fs.BaseFolder; + var projectPath = Path.Combine(baseFolder, "MsiPackage.wixproj"); // Build var result = MsbuildRunner.Execute(projectPath, new[] { $"-p:WixTargetsPath={WixTargetsPath}", - $"-p:IntermediateOutputPath={intermediateFolder}", - $"-p:OutputPath={binFolder}", "-v:diag" }); result.AssertSuccess(); @@ -270,8 +273,6 @@ namespace WixToolsetTest.MSBuild result = MsbuildRunner.Execute(projectPath, new[] { $"-p:WixTargetsPath={WixTargetsPath}", - $"-p:IntermediateOutputPath={intermediateFolder}", - $"-p:OutputPath={binFolder}", "-t:Clean", "-v:diag" }); @@ -281,9 +282,19 @@ namespace WixToolsetTest.MSBuild // Clean is only expected to delete the files listed in {Project}.FileListAbsolute.txt, // so this is not quite right but close enough. + var allowedFiles = new HashSet + { + "MsiPackage.wixproj", + "Package.en-us.wxl", + "Package.wxs", + "PackageComponents.wxs", + @"data\test.txt", + @"obj\x86\Debug\MsiPackage.wixproj.FileListAbsolute.txt", + }; + var remainingPaths = Directory.EnumerateFiles(baseFolder, @"*.*", SearchOption.AllDirectories) .Select(s => s.Substring(baseFolder.Length + 1)) - .Where(s => s != "obj\\MsiPackage.wixproj.FileListAbsolute.txt") + .Where(s => !allowedFiles.Contains(s)) .OrderBy(s => s) .ToArray(); Assert.Empty(remainingPaths); diff --git a/src/test/WixToolsetTest.MSBuild/MsbuildHeatFixture.cs b/src/test/WixToolsetTest.MSBuild/MsbuildHeatFixture.cs index fa8acb81..b5331cbc 100644 --- a/src/test/WixToolsetTest.MSBuild/MsbuildHeatFixture.cs +++ b/src/test/WixToolsetTest.MSBuild/MsbuildHeatFixture.cs @@ -18,19 +18,19 @@ namespace WixToolsetTest.MSBuild [Fact] public void CanBuildHeatFilePackage() { - var projectPath = TestData.Get(@"TestData\HeatFilePackage\HeatFilePackage.wixproj"); + var sourceFolder = TestData.Get(@"TestData\HeatFilePackage"); - using (var fs = new DisposableFileSystem()) + using (var fs = new TestDataFolderFileSystem()) { - var baseFolder = fs.GetFolder(); + fs.Initialize(sourceFolder); + var baseFolder = fs.BaseFolder; var binFolder = Path.Combine(baseFolder, @"bin\"); var intermediateFolder = Path.Combine(baseFolder, @"obj\"); + var projectPath = Path.Combine(baseFolder, "HeatFilePackage.wixproj"); var result = MsbuildRunner.Execute(projectPath, new[] { $"-p:WixTargetsPath={WixTargetsPath}", - $"-p:IntermediateOutputPath={intermediateFolder}", - $"-p:OutputPath={binFolder}" }); result.AssertSuccess(); @@ -40,7 +40,7 @@ namespace WixToolsetTest.MSBuild var warnings = result.Output.Where(line => line.Contains(": warning")); Assert.Empty(warnings); - var generatedFilePath = Path.Combine(intermediateFolder, @"_ProductComponents_INSTALLFOLDER_HeatFilePackage.wixproj_file.wxs"); + var generatedFilePath = Path.Combine(intermediateFolder, "x86", "Debug", "_ProductComponents_INSTALLFOLDER_HeatFilePackage.wixproj_file.wxs"); Assert.True(File.Exists(generatedFilePath)); var generatedContents = File.ReadAllText(generatedFilePath); @@ -60,7 +60,7 @@ namespace WixToolsetTest.MSBuild "" + "", testXml); - var pdbPath = Path.Combine(binFolder, "HeatFilePackage.wixpdb"); + var pdbPath = Path.Combine(binFolder, "x86", "Debug", "HeatFilePackage.wixpdb"); Assert.True(File.Exists(pdbPath)); var intermediate = Intermediate.Load(pdbPath); @@ -74,19 +74,19 @@ namespace WixToolsetTest.MSBuild [Fact] public void CanBuildHeatFileWithMultipleFilesPackage() { - var projectPath = TestData.Get(@"TestData\HeatFileMultipleFilesSameFileName\HeatFileMultipleFilesSameFileName.wixproj"); + var sourceFolder = TestData.Get(@"TestData\HeatFileMultipleFilesSameFileName"); - using (var fs = new DisposableFileSystem()) + using (var fs = new TestDataFolderFileSystem()) { - var baseFolder = fs.GetFolder(); + fs.Initialize(sourceFolder); + var baseFolder = fs.BaseFolder; var binFolder = Path.Combine(baseFolder, @"bin\"); var intermediateFolder = Path.Combine(baseFolder, @"obj\"); + var projectPath = Path.Combine(baseFolder, "HeatFileMultipleFilesSameFileName.wixproj"); var result = MsbuildRunner.Execute(projectPath, new[] { $"-p:WixTargetsPath={WixTargetsPath}", - $"-p:IntermediateOutputPath={intermediateFolder}", - $"-p:OutputPath={binFolder}" }); result.AssertSuccess(); @@ -96,7 +96,7 @@ namespace WixToolsetTest.MSBuild var warnings = result.Output.Where(line => line.Contains(": warning")); Assert.Empty(warnings); - var generatedFilePath = Path.Combine(intermediateFolder, @"_TxtProductComponents_INSTALLFOLDER_MyProgram.txt_file.wxs"); + var generatedFilePath = Path.Combine(intermediateFolder, "x86", "Debug", "_TxtProductComponents_INSTALLFOLDER_MyProgram.txt_file.wxs"); Assert.True(File.Exists(generatedFilePath)); var generatedContents = File.ReadAllText(generatedFilePath); @@ -116,7 +116,7 @@ namespace WixToolsetTest.MSBuild "" + "", testXml); - generatedFilePath = Path.Combine(intermediateFolder, @"_JsonProductComponents_INSTALLFOLDER_MyProgram.json_file.wxs"); + generatedFilePath = Path.Combine(intermediateFolder, "x86", "Debug", "_JsonProductComponents_INSTALLFOLDER_MyProgram.json_file.wxs"); Assert.True(File.Exists(generatedFilePath)); generatedContents = File.ReadAllText(generatedFilePath); @@ -136,7 +136,7 @@ namespace WixToolsetTest.MSBuild "" + "", testXml); - var pdbPath = Path.Combine(binFolder, "HeatFileMultipleFilesSameFileName.wixpdb"); + var pdbPath = Path.Combine(binFolder, "x86", "Debug", "HeatFileMultipleFilesSameFileName.wixpdb"); Assert.True(File.Exists(pdbPath)); var intermediate = Intermediate.Load(pdbPath); -- cgit v1.2.3-55-g6feb