diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2020-05-30 18:55:10 +1000 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2020-05-31 15:11:21 +1000 |
| commit | 64fe8bccc329ac5dc0d510bfbd73054d478ddc37 (patch) | |
| tree | 21cc3d21b3b3a689e434f5a387ad98551eb3486c /src/test/WixToolsetTest.BuildTasks/MsbuildFixture.cs | |
| parent | 2b9f1c20452b582af1962449e0b662d6ec942728 (diff) | |
| download | wix-64fe8bccc329ac5dc0d510bfbd73054d478ddc37.tar.gz wix-64fe8bccc329ac5dc0d510bfbd73054d478ddc37.tar.bz2 wix-64fe8bccc329ac5dc0d510bfbd73054d478ddc37.zip | |
Move most tests into the new WixToolsetTest.MSBuild project.
This project relies on all of the projects being published in order to properly test wix.targets.
Diffstat (limited to 'src/test/WixToolsetTest.BuildTasks/MsbuildFixture.cs')
| -rw-r--r-- | src/test/WixToolsetTest.BuildTasks/MsbuildFixture.cs | 304 |
1 files changed, 0 insertions, 304 deletions
diff --git a/src/test/WixToolsetTest.BuildTasks/MsbuildFixture.cs b/src/test/WixToolsetTest.BuildTasks/MsbuildFixture.cs deleted file mode 100644 index 0768f863..00000000 --- a/src/test/WixToolsetTest.BuildTasks/MsbuildFixture.cs +++ /dev/null | |||
| @@ -1,304 +0,0 @@ | |||
| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 2 | |||
| 3 | namespace WixToolsetTest.BuildTasks | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.IO; | ||
| 7 | using System.Linq; | ||
| 8 | using WixBuildTools.TestSupport; | ||
| 9 | using WixToolset.BuildTasks; | ||
| 10 | using Xunit; | ||
| 11 | |||
| 12 | public class MsbuildFixture | ||
| 13 | { | ||
| 14 | private static readonly string WixBinPath = Path.GetDirectoryName(new Uri(typeof(WixBuild).Assembly.CodeBase).AbsolutePath) + "\\"; | ||
| 15 | private static readonly string WixTargetsPath = Path.Combine(WixBinPath, "wix.targets"); | ||
| 16 | |||
| 17 | [Fact] | ||
| 18 | public void CanBuildSimpleBundle() | ||
| 19 | { | ||
| 20 | var projectPath = TestData.Get(@"TestData\SimpleMsiPackage\SimpleBundle\SimpleBundle.wixproj"); | ||
| 21 | |||
| 22 | using (var fs = new DisposableFileSystem()) | ||
| 23 | { | ||
| 24 | var baseFolder = fs.GetFolder(); | ||
| 25 | var binFolder = Path.Combine(baseFolder, @"bin\"); | ||
| 26 | var intermediateFolder = Path.Combine(baseFolder, @"obj\"); | ||
| 27 | |||
| 28 | var result = MsbuildRunner.Execute(projectPath, new[] | ||
| 29 | { | ||
| 30 | $"-p:WixTargetsPath={WixTargetsPath}", | ||
| 31 | $"-p:WixBinDir={WixBinPath}", | ||
| 32 | $"-p:IntermediateOutputPath={intermediateFolder}", | ||
| 33 | $"-p:OutputPath={binFolder}" | ||
| 34 | }); | ||
| 35 | result.AssertSuccess(); | ||
| 36 | |||
| 37 | var platformSwitches = result.Output.Where(line => line.TrimStart().StartsWith("wix.exe build -platform x86")); | ||
| 38 | Assert.Single(platformSwitches); | ||
| 39 | |||
| 40 | var warnings = result.Output.Where(line => line.Contains(": warning")); | ||
| 41 | Assert.Empty(warnings); | ||
| 42 | |||
| 43 | var paths = Directory.EnumerateFiles(binFolder, @"*.*", SearchOption.AllDirectories) | ||
| 44 | .Select(s => s.Substring(baseFolder.Length + 1)) | ||
| 45 | .OrderBy(s => s) | ||
| 46 | .ToArray(); | ||
| 47 | Assert.Equal(new[] | ||
| 48 | { | ||
| 49 | @"bin\SimpleBundle.exe", | ||
| 50 | @"bin\SimpleBundle.wixpdb", | ||
| 51 | }, paths); | ||
| 52 | } | ||
| 53 | } | ||
| 54 | |||
| 55 | [Fact] | ||
| 56 | public void CanBuildSimpleMsiPackage() | ||
| 57 | { | ||
| 58 | var projectPath = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage\MsiPackage.wixproj"); | ||
| 59 | |||
| 60 | using (var fs = new DisposableFileSystem()) | ||
| 61 | { | ||
| 62 | var baseFolder = fs.GetFolder(); | ||
| 63 | var binFolder = Path.Combine(baseFolder, @"bin\"); | ||
| 64 | var intermediateFolder = Path.Combine(baseFolder, @"obj\"); | ||
| 65 | |||
| 66 | var result = MsbuildRunner.Execute(projectPath, new[] | ||
| 67 | { | ||
| 68 | $"-p:WixTargetsPath={WixTargetsPath}", | ||
| 69 | $"-p:WixBinDir={WixBinPath}", | ||
| 70 | $"-p:IntermediateOutputPath={intermediateFolder}", | ||
| 71 | $"-p:OutputPath={binFolder}" | ||
| 72 | }); | ||
| 73 | result.AssertSuccess(); | ||
| 74 | |||
| 75 | var platformSwitches = result.Output.Where(line => line.TrimStart().StartsWith("wix.exe build -platform x86")); | ||
| 76 | Assert.Single(platformSwitches); | ||
| 77 | |||
| 78 | var warnings = result.Output.Where(line => line.Contains(": warning")); | ||
| 79 | Assert.Equal(4, warnings.Count()); | ||
| 80 | |||
| 81 | var paths = Directory.EnumerateFiles(binFolder, @"*.*", SearchOption.AllDirectories) | ||
| 82 | .Select(s => s.Substring(baseFolder.Length + 1)) | ||
| 83 | .OrderBy(s => s) | ||
| 84 | .ToArray(); | ||
| 85 | Assert.Equal(new[] | ||
| 86 | { | ||
| 87 | @"bin\en-US\cab1.cab", | ||
| 88 | @"bin\en-US\MsiPackage.msi", | ||
| 89 | @"bin\en-US\MsiPackage.wixpdb", | ||
| 90 | }, paths); | ||
| 91 | } | ||
| 92 | } | ||
| 93 | |||
| 94 | [Fact] | ||
| 95 | public void CanBuildWithDefaultAndExplicitlyFullWixpdbs() | ||
| 96 | { | ||
| 97 | var expectedOutputs = new[] | ||
| 98 | { | ||
| 99 | @"bin\en-US\cab1.cab", | ||
| 100 | @"bin\en-US\MsiPackage.msi", | ||
| 101 | @"bin\en-US\MsiPackage.wixpdb", | ||
| 102 | }; | ||
| 103 | |||
| 104 | this.AssertWixpdb(null, expectedOutputs); | ||
| 105 | this.AssertWixpdb("Full", expectedOutputs); | ||
| 106 | } | ||
| 107 | |||
| 108 | [Fact] | ||
| 109 | public void CanBuildWithNoWixpdb() | ||
| 110 | { | ||
| 111 | this.AssertWixpdb("NONE", new[] | ||
| 112 | { | ||
| 113 | @"bin\en-US\cab1.cab", | ||
| 114 | @"bin\en-US\MsiPackage.msi", | ||
| 115 | }); | ||
| 116 | } | ||
| 117 | |||
| 118 | private void AssertWixpdb(string wixpdbType, string[] expectedOutputFiles) | ||
| 119 | { | ||
| 120 | var projectPath = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage\MsiPackage.wixproj"); | ||
| 121 | |||
| 122 | using (var fs = new DisposableFileSystem()) | ||
| 123 | { | ||
| 124 | var baseFolder = fs.GetFolder(); | ||
| 125 | var binFolder = Path.Combine(baseFolder, @"bin\"); | ||
| 126 | var intermediateFolder = Path.Combine(baseFolder, @"obj\"); | ||
| 127 | |||
| 128 | var result = MsbuildRunner.Execute(projectPath, new[] | ||
| 129 | { | ||
| 130 | wixpdbType == null ? String.Empty : $"-p:WixPdbType={wixpdbType}", | ||
| 131 | $"-p:WixTargetsPath={WixTargetsPath}", | ||
| 132 | $"-p:WixBinDir={WixBinPath}", | ||
| 133 | $"-p:IntermediateOutputPath={intermediateFolder}", | ||
| 134 | $"-p:OutputPath={binFolder}", | ||
| 135 | }); | ||
| 136 | result.AssertSuccess(); | ||
| 137 | |||
| 138 | var paths = Directory.EnumerateFiles(binFolder, @"*.*", SearchOption.AllDirectories) | ||
| 139 | .Select(s => s.Substring(baseFolder.Length + 1)) | ||
| 140 | .OrderBy(s => s) | ||
| 141 | .ToArray(); | ||
| 142 | Assert.Equal(expectedOutputFiles, paths); | ||
| 143 | } | ||
| 144 | } | ||
| 145 | |||
| 146 | [Fact] | ||
| 147 | public void CanBuild64BitMsiPackage() | ||
| 148 | { | ||
| 149 | var projectPath = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage\MsiPackage.wixproj"); | ||
| 150 | |||
| 151 | using (var fs = new DisposableFileSystem()) | ||
| 152 | { | ||
| 153 | var baseFolder = fs.GetFolder(); | ||
| 154 | var binFolder = Path.Combine(baseFolder, @"bin\"); | ||
| 155 | var intermediateFolder = Path.Combine(baseFolder, @"obj\"); | ||
| 156 | |||
| 157 | var result = MsbuildRunner.Execute(projectPath, new[] | ||
| 158 | { | ||
| 159 | $"-p:WixTargetsPath={WixTargetsPath}", | ||
| 160 | $"-p:WixBinDir={WixBinPath}", | ||
| 161 | $"-p:IntermediateOutputPath={intermediateFolder}", | ||
| 162 | $"-p:OutputPath={binFolder}", | ||
| 163 | $"-p:InstallerPlatform=x64", | ||
| 164 | }); | ||
| 165 | result.AssertSuccess(); | ||
| 166 | |||
| 167 | var platformSwitches = result.Output.Where(line => line.TrimStart().StartsWith("wix.exe build -platform x64")); | ||
| 168 | Assert.Single(platformSwitches); | ||
| 169 | } | ||
| 170 | } | ||
| 171 | |||
| 172 | [Fact(Skip = "Currently fails")] | ||
| 173 | public void CanBuildSimpleMsiPackageWithIceSuppressions() | ||
| 174 | { | ||
| 175 | var projectPath = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage\MsiPackage.wixproj"); | ||
| 176 | |||
| 177 | using (var fs = new DisposableFileSystem()) | ||
| 178 | { | ||
| 179 | var baseFolder = fs.GetFolder(); | ||
| 180 | var binFolder = Path.Combine(baseFolder, @"bin\"); | ||
| 181 | var intermediateFolder = Path.Combine(baseFolder, @"obj\"); | ||
| 182 | |||
| 183 | var result = MsbuildRunner.Execute(projectPath, new[] | ||
| 184 | { | ||
| 185 | $"-p:WixTargetsPath={WixTargetsPath}", | ||
| 186 | $"-p:WixBinDir={WixBinPath}", | ||
| 187 | $"-p:IntermediateOutputPath={intermediateFolder}", | ||
| 188 | $"-p:OutputPath={binFolder}", | ||
| 189 | "-p:SuppressIces=\"ICE45;ICE46\"" | ||
| 190 | }); | ||
| 191 | result.AssertSuccess(); | ||
| 192 | } | ||
| 193 | } | ||
| 194 | |||
| 195 | [Fact] | ||
| 196 | public void CanBuildSimpleMsiPackageWithWarningSuppressions() | ||
| 197 | { | ||
| 198 | var projectPath = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage\MsiPackage.wixproj"); | ||
| 199 | |||
| 200 | using (var fs = new DisposableFileSystem()) | ||
| 201 | { | ||
| 202 | var baseFolder = fs.GetFolder(); | ||
| 203 | var binFolder = Path.Combine(baseFolder, @"bin\"); | ||
| 204 | var intermediateFolder = Path.Combine(baseFolder, @"obj\"); | ||
| 205 | |||
| 206 | var result = MsbuildRunner.Execute(projectPath, new[] | ||
| 207 | { | ||
| 208 | $"-p:WixTargetsPath={WixTargetsPath}", | ||
| 209 | $"-p:WixBinDir={WixBinPath}", | ||
| 210 | $"-p:IntermediateOutputPath={intermediateFolder}", | ||
| 211 | $"-p:OutputPath={binFolder}", | ||
| 212 | "-p:SuppressSpecificWarnings=\"1118;1102\"" | ||
| 213 | }); | ||
| 214 | result.AssertSuccess(); | ||
| 215 | |||
| 216 | var warnings = result.Output.Where(line => line.Contains(": warning")); | ||
| 217 | Assert.Empty(warnings); | ||
| 218 | } | ||
| 219 | } | ||
| 220 | |||
| 221 | [Fact] | ||
| 222 | public void CanBuildSimpleMsiPackageAsWixipl() | ||
| 223 | { | ||
| 224 | var projectPath = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage\MsiPackage.wixproj"); | ||
| 225 | |||
| 226 | using (var fs = new DisposableFileSystem()) | ||
| 227 | { | ||
| 228 | var baseFolder = fs.GetFolder(); | ||
| 229 | var binFolder = Path.Combine(baseFolder, @"bin\"); | ||
| 230 | var intermediateFolder = Path.Combine(baseFolder, @"obj\"); | ||
| 231 | |||
| 232 | var result = MsbuildRunner.Execute(projectPath, new[] | ||
| 233 | { | ||
| 234 | $"-p:WixTargetsPath={WixTargetsPath}", | ||
| 235 | $"-p:WixBinDir={WixBinPath}", | ||
| 236 | $"-p:IntermediateOutputPath={intermediateFolder}", | ||
| 237 | $"-p:OutputPath={binFolder}", | ||
| 238 | "-p:OutputType=IntermediatePostLink" | ||
| 239 | }); | ||
| 240 | result.AssertSuccess(); | ||
| 241 | |||
| 242 | var path = Directory.EnumerateFiles(binFolder, @"*.*", SearchOption.AllDirectories) | ||
| 243 | .Select(s => s.Substring(baseFolder.Length + 1)) | ||
| 244 | .Single(); | ||
| 245 | Assert.Equal(@"bin\MsiPackage.wixipl", path); | ||
| 246 | } | ||
| 247 | } | ||
| 248 | |||
| 249 | [Fact] | ||
| 250 | public void CanBuildAndCleanSimpleMsiPackage() | ||
| 251 | { | ||
| 252 | var projectPath = TestData.Get(@"TestData\SimpleMsiPackage\MsiPackage\MsiPackage.wixproj"); | ||
| 253 | |||
| 254 | using (var fs = new DisposableFileSystem()) | ||
| 255 | { | ||
| 256 | var baseFolder = fs.GetFolder(); | ||
| 257 | var binFolder = Path.Combine(baseFolder, @"bin\"); | ||
| 258 | var intermediateFolder = Path.Combine(baseFolder, @"obj\"); | ||
| 259 | |||
| 260 | // Build | ||
| 261 | var result = MsbuildRunner.Execute(projectPath, new[] | ||
| 262 | { | ||
| 263 | $"-p:WixTargetsPath={WixTargetsPath}", | ||
| 264 | $"-p:WixBinDir={WixBinPath}", | ||
| 265 | $"-p:IntermediateOutputPath={intermediateFolder}", | ||
| 266 | $"-p:OutputPath={binFolder}", | ||
| 267 | "-v:diag" | ||
| 268 | }); | ||
| 269 | result.AssertSuccess(); | ||
| 270 | |||
| 271 | var buildOutput = String.Join("\r\n", result.Output); | ||
| 272 | |||
| 273 | var createdPaths = Directory.EnumerateFiles(baseFolder, @"*.*", SearchOption.AllDirectories) | ||
| 274 | .Select(s => s.Substring(baseFolder.Length + 1)) | ||
| 275 | .OrderBy(s => s) | ||
| 276 | .ToArray(); | ||
| 277 | Assert.NotEmpty(createdPaths); | ||
| 278 | |||
| 279 | // Clean | ||
| 280 | result = MsbuildRunner.Execute(projectPath, new[] | ||
| 281 | { | ||
| 282 | $"-p:WixTargetsPath={WixTargetsPath}", | ||
| 283 | $"-p:WixBinDir={WixBinPath}", | ||
| 284 | $"-p:IntermediateOutputPath={intermediateFolder}", | ||
| 285 | $"-p:OutputPath={binFolder}", | ||
| 286 | "-t:Clean", | ||
| 287 | "-v:diag" | ||
| 288 | }); | ||
| 289 | result.AssertSuccess(); | ||
| 290 | |||
| 291 | var cleanOutput = String.Join("\r\n", result.Output); | ||
| 292 | |||
| 293 | // Clean is only expected to delete the files listed in {Project}.FileListAbsolute.txt, | ||
| 294 | // so this is not quite right but close enough. | ||
| 295 | var remainingPaths = Directory.EnumerateFiles(baseFolder, @"*.*", SearchOption.AllDirectories) | ||
| 296 | .Select(s => s.Substring(baseFolder.Length + 1)) | ||
| 297 | .Where(s => s != "obj\\MsiPackage.wixproj.FileListAbsolute.txt") | ||
| 298 | .OrderBy(s => s) | ||
| 299 | .ToArray(); | ||
| 300 | Assert.Empty(remainingPaths); | ||
| 301 | } | ||
| 302 | } | ||
| 303 | } | ||
| 304 | } | ||
