| 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.BootstrapperApplications |
| 4 | { |
| 5 | using System.IO; |
| 6 | using System.Linq; |
| 7 | using System.Xml; |
| 8 | using WixInternal.Core.TestPackage; |
| 9 | using WixInternal.TestSupport; |
| 10 | using Xunit; |
| 11 | |
| 12 | public class InternalUIBAFixture |
| 13 | { |
| 14 | [Fact] |
| 15 | public void CanBuildUsingWixIuiBa() |
| 16 | { |
| 17 | using (var fs = new DisposableFileSystem()) |
| 18 | { |
| 19 | var baseFolder = fs.GetFolder(); |
| 20 | var bundleFile = Path.Combine(baseFolder, "bin", "test.exe"); |
| 21 | var bundleSourceFolder = TestData.Get(@"TestData\WixIuiBa"); |
| 22 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 23 | var baFolderPath = Path.Combine(baseFolder, "ba"); |
| 24 | var extractFolderPath = Path.Combine(baseFolder, "extract"); |
| 25 | |
| 26 | var compileResult = WixRunner.Execute(new[] |
| 27 | { |
| 28 | "build", |
| 29 | Path.Combine(bundleSourceFolder, "SinglePrimaryPackage.wxs"), |
| 30 | "-ext", TestData.Get(@"WixToolset.BootstrapperApplications.wixext.dll"), |
| 31 | "-intermediateFolder", intermediateFolder, |
| 32 | "-bindpath", TestData.Get(@"TestData\WixStdBa\Data"), |
| 33 | "-o", bundleFile, |
| 34 | }); |
| 35 | compileResult.AssertSuccess(); |
| 36 | |
| 37 | Assert.True(File.Exists(bundleFile)); |
| 38 | |
| 39 | var extractResult = BundleExtractor.ExtractBAContainer(null, bundleFile, baFolderPath, extractFolderPath); |
| 40 | extractResult.AssertSuccess(); |
| 41 | |
| 42 | var balPackageInfos = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixBalPackageInfo"); |
| 43 | WixAssert.CompareLineByLine(new string[] |
| 44 | { |
| 45 | "<WixBalPackageInfo PackageId='test.msi' PrimaryPackageType='default' />", |
| 46 | }, balPackageInfos); |
| 47 | |
| 48 | Assert.True(File.Exists(Path.Combine(baFolderPath, "wixpreq.thm"))); |
| 49 | Assert.True(File.Exists(Path.Combine(baFolderPath, "wixpreq.wxl"))); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | [Fact] |
| 54 | public void CanBuildUsingWixIuiBaWithUrlPrereqPackage() |
| 55 | { |
| 56 | using (var fs = new DisposableFileSystem()) |
| 57 | { |
| 58 | var baseFolder = fs.GetFolder(); |
| 59 | var bundleFile = Path.Combine(baseFolder, "bin", "test.exe"); |
| 60 | var bundleSourceFolder = TestData.Get(@"TestData\WixIuiBa"); |
| 61 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 62 | var baFolderPath = Path.Combine(baseFolder, "ba"); |
| 63 | var extractFolderPath = Path.Combine(baseFolder, "extract"); |
| 64 | |
| 65 | var compileResult = WixRunner.Execute(new[] |
| 66 | { |
| 67 | "build", |
| 68 | Path.Combine(bundleSourceFolder, "UrlPrereqPackage.wxs"), |
| 69 | "-ext", TestData.Get(@"WixToolset.BootstrapperApplications.wixext.dll"), |
| 70 | "-intermediateFolder", intermediateFolder, |
| 71 | "-bindpath", TestData.Get(@"TestData\WixStdBa\Data"), |
| 72 | "-o", bundleFile, |
| 73 | }); |
| 74 | compileResult.AssertSuccess(); |
| 75 | |
| 76 | Assert.True(File.Exists(bundleFile)); |
| 77 | |
| 78 | var extractResult = BundleExtractor.ExtractBAContainer(null, bundleFile, baFolderPath, extractFolderPath); |
| 79 | extractResult.AssertSuccess(); |
| 80 | |
| 81 | var balPackageInfos = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixBalPackageInfo"); |
| 82 | WixAssert.CompareLineByLine(new string[] |
| 83 | { |
| 84 | "<WixBalPackageInfo PackageId='test.msi' PrimaryPackageType='default' />", |
| 85 | }, balPackageInfos); |
| 86 | |
| 87 | var mbaPrereqInfos = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixPrereqInformation"); |
| 88 | WixAssert.CompareLineByLine(new[] |
| 89 | { |
| 90 | "<WixPrereqInformation PackageId='wixnative.exe' LicenseUrl='https://www.mysite.com/prereqterms' />", |
| 91 | }, mbaPrereqInfos); |
| 92 | |
| 93 | Assert.True(File.Exists(Path.Combine(baFolderPath, "wixpreq.thm"))); |
| 94 | Assert.True(File.Exists(Path.Combine(baFolderPath, "wixpreq.wxl"))); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | [Fact] |
| 99 | public void CanBuildUsingWixIuiBaWithImplicitPrimaryPackage() |
| 100 | { |
| 101 | using (var fs = new DisposableFileSystem()) |
| 102 | { |
| 103 | var baseFolder = fs.GetFolder(); |
| 104 | var bundleFile = Path.Combine(baseFolder, "bin", "test.exe"); |
| 105 | var bundleSourceFolder = TestData.Get(@"TestData\WixIuiBa"); |
| 106 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 107 | var baFolderPath = Path.Combine(baseFolder, "ba"); |
| 108 | var extractFolderPath = Path.Combine(baseFolder, "extract"); |
| 109 | |
| 110 | var compileResult = WixRunner.Execute(new[] |
| 111 | { |
| 112 | "build", |
| 113 | Path.Combine(bundleSourceFolder, "ImplicitPrimaryPackage.wxs"), |
| 114 | "-ext", TestData.Get(@"WixToolset.BootstrapperApplications.wixext.dll"), |
| 115 | "-intermediateFolder", intermediateFolder, |
| 116 | "-bindpath", TestData.Get(@"TestData\WixStdBa\Data"), |
| 117 | "-o", bundleFile, |
| 118 | }); |
| 119 | compileResult.AssertSuccess(); |
| 120 | |
| 121 | Assert.True(File.Exists(bundleFile)); |
| 122 | |
| 123 | var extractResult = BundleExtractor.ExtractBAContainer(null, bundleFile, baFolderPath, extractFolderPath); |
| 124 | extractResult.AssertSuccess(); |
| 125 | |
| 126 | var balPackageInfos = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixBalPackageInfo"); |
| 127 | WixAssert.CompareLineByLine(new string[] |
| 128 | { |
| 129 | "<WixBalPackageInfo PackageId='test.msi' PrimaryPackageType='default' />", |
| 130 | }, balPackageInfos); |
| 131 | |
| 132 | var mbaPrereqInfos = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixPrereqInformation"); |
| 133 | WixAssert.CompareLineByLine(new[] |
| 134 | { |
| 135 | "<WixPrereqInformation PackageId='wixnative.exe' />", |
| 136 | }, mbaPrereqInfos); |
| 137 | |
| 138 | Assert.True(File.Exists(Path.Combine(baFolderPath, "wixpreq.thm"))); |
| 139 | Assert.True(File.Exists(Path.Combine(baFolderPath, "wixpreq.wxl"))); |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | [Fact] |
| 144 | public void CanBuildUsingWixIuiBaWithWarnings() |
| 145 | { |
| 146 | using (var fs = new DisposableFileSystem()) |
| 147 | { |
| 148 | var baseFolder = fs.GetFolder(); |
| 149 | var bundleFile = Path.Combine(baseFolder, "bin", "test.exe"); |
| 150 | var bundleSourceFolder = TestData.Get(@"TestData\WixIuiBa"); |
| 151 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 152 | var baFolderPath = Path.Combine(baseFolder, "ba"); |
| 153 | var extractFolderPath = Path.Combine(baseFolder, "extract"); |
| 154 | |
| 155 | var compileResult = WixRunner.Execute(warningsAsErrors: false, new[] |
| 156 | { |
| 157 | "build", |
| 158 | Path.Combine(bundleSourceFolder, "IuiBaWarnings.wxs"), |
| 159 | "-ext", TestData.Get(@"WixToolset.BootstrapperApplications.wixext.dll"), |
| 160 | "-intermediateFolder", intermediateFolder, |
| 161 | "-bindpath", TestData.Get(@"TestData\WixStdBa\Data"), |
| 162 | "-o", bundleFile, |
| 163 | }); |
| 164 | |
| 165 | WixAssert.CompareLineByLine(new[] |
| 166 | { |
| 167 | "WixInternalUIBootstrapperApplication does not support the value of 'force' for Cache on prereq packages. Prereq packages are only cached when they need to be installed.", |
| 168 | "WixInternalUIBootstrapperApplication ignores InstallCondition for the primary package so that the MSI UI is always shown.", |
| 169 | "WixInternalUIBootstrapperApplication ignores DisplayInternalUICondition for the primary package so that the MSI UI is always shown.", |
| 170 | "When using WixInternalUIBootstrapperApplication, all prereq packages should be before the primary package in the chain. The prereq packages are always installed before the primary package.", |
| 171 | }, compileResult.Messages.Select(m => m.ToString()).ToArray()); |
| 172 | |
| 173 | compileResult.AssertSuccess(); |
| 174 | |
| 175 | Assert.True(File.Exists(bundleFile)); |
| 176 | |
| 177 | var extractResult = BundleExtractor.ExtractBAContainer(null, bundleFile, baFolderPath, extractFolderPath); |
| 178 | extractResult.AssertSuccess(); |
| 179 | |
| 180 | var balPackageInfos = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixBalPackageInfo"); |
| 181 | WixAssert.CompareLineByLine(new string[] |
| 182 | { |
| 183 | "<WixBalPackageInfo PackageId='test.msi' DisplayInternalUICondition='DISPLAYTEST' PrimaryPackageType='default' />", |
| 184 | }, balPackageInfos); |
| 185 | |
| 186 | var mbaPrereqInfos = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixPrereqInformation"); |
| 187 | WixAssert.CompareLineByLine(new[] |
| 188 | { |
| 189 | "<WixPrereqInformation PackageId='wixnative.exe' />", |
| 190 | }, mbaPrereqInfos); |
| 191 | |
| 192 | Assert.True(File.Exists(Path.Combine(baFolderPath, "wixpreq.thm"))); |
| 193 | Assert.True(File.Exists(Path.Combine(baFolderPath, "wixpreq.wxl"))); |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | [Fact] |
| 198 | public void CanBuildUsingWixIuiBaAndForcedCachePrimaryPackage() |
| 199 | { |
| 200 | using (var fs = new DisposableFileSystem()) |
| 201 | { |
| 202 | var baseFolder = fs.GetFolder(); |
| 203 | var bundleFile = Path.Combine(baseFolder, "bin", "test.exe"); |
| 204 | var bundleSourceFolder = TestData.Get(@"TestData\WixIuiBa"); |
| 205 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 206 | var baFolderPath = Path.Combine(baseFolder, "ba"); |
| 207 | var extractFolderPath = Path.Combine(baseFolder, "extract"); |
| 208 | |
| 209 | var compileResult = WixRunner.Execute(warningsAsErrors: false, new[] |
| 210 | { |
| 211 | "build", |
| 212 | Path.Combine(bundleSourceFolder, "CanForceCachePrimaryPackage.wxs"), |
| 213 | "-ext", TestData.Get(@"WixToolset.BootstrapperApplications.wixext.dll"), |
| 214 | "-intermediateFolder", intermediateFolder, |
| 215 | "-bindpath", TestData.Get(@"TestData\WixStdBa\Data"), |
| 216 | "-o", bundleFile, |
| 217 | }); |
| 218 | |
| 219 | compileResult.AssertSuccess(); |
| 220 | |
| 221 | Assert.True(File.Exists(bundleFile)); |
| 222 | |
| 223 | var extractResult = BundleExtractor.ExtractBAContainer(null, bundleFile, baFolderPath, extractFolderPath); |
| 224 | extractResult.AssertSuccess(); |
| 225 | |
| 226 | var wixPackageProperties = extractResult.SelectBADataNodes("/ba:BootstrapperApplicationData/ba:WixPackageProperties"); |
| 227 | AssertCacheType(wixPackageProperties[0]); |
| 228 | AssertCacheType(wixPackageProperties[1]); |
| 229 | |
| 230 | var balPackageInfos = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixBalPackageInfo"); |
| 231 | WixAssert.CompareLineByLine(new string[] |
| 232 | { |
| 233 | "<WixBalPackageInfo PackageId='test.msi' PrimaryPackageType='default' />", |
| 234 | }, balPackageInfos); |
| 235 | |
| 236 | var mbaPrereqInfos = extractResult.GetBADataTestXmlLines("/ba:BootstrapperApplicationData/ba:WixPrereqInformation"); |
| 237 | WixAssert.CompareLineByLine(new[] |
| 238 | { |
| 239 | "<WixPrereqInformation PackageId='wixnative.exe' />", |
| 240 | }, mbaPrereqInfos); |
| 241 | |
| 242 | Assert.True(File.Exists(Path.Combine(baFolderPath, "wixpreq.thm"))); |
| 243 | Assert.True(File.Exists(Path.Combine(baFolderPath, "wixpreq.wxl"))); |
| 244 | } |
| 245 | |
| 246 | static void AssertCacheType(XmlNode node) |
| 247 | { |
| 248 | var element = node as XmlElement; |
| 249 | var package = element?.GetAttribute("Package"); |
| 250 | var cache = element?.GetAttribute("Cache"); |
| 251 | |
| 252 | if (package == "test.msi") |
| 253 | { |
| 254 | Assert.Equal("force", cache); |
| 255 | } |
| 256 | else if (package == "wixnative.exe") |
| 257 | { |
| 258 | Assert.Equal("keep", cache); |
| 259 | } |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | [Fact] |
| 264 | public void CannotBuildUsingWixIuiBaWithAllPrereqPackages() |
| 265 | { |
| 266 | using (var fs = new DisposableFileSystem()) |
| 267 | { |
| 268 | var baseFolder = fs.GetFolder(); |
| 269 | var bundleFile = Path.Combine(baseFolder, "bin", "test.exe"); |
| 270 | var bundleSourceFolder = TestData.Get(@"TestData\WixIuiBa"); |
| 271 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 272 | |
| 273 | var compileResult = WixRunner.Execute(new[] |
| 274 | { |
| 275 | "build", |
| 276 | Path.Combine(bundleSourceFolder, "AllPrereqPackages.wxs"), |
| 277 | "-ext", TestData.Get(@"WixToolset.BootstrapperApplications.wixext.dll"), |
| 278 | "-intermediateFolder", intermediateFolder, |
| 279 | "-bindpath", TestData.Get(@"TestData\WixStdBa\Data"), |
| 280 | "-o", bundleFile, |
| 281 | }); |
| 282 | |
| 283 | WixAssert.CompareLineByLine(new[] |
| 284 | { |
| 285 | "When using WixInternalUIBootstrapperApplication, there must be one package with bal:PrimaryPackageType=\"default\".", |
| 286 | }, compileResult.Messages.Select(m => m.ToString()).ToArray()); |
| 287 | |
| 288 | Assert.Equal(6808, compileResult.ExitCode); |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | [Fact] |
| 293 | public void CannotBuildUsingWixIuiBaWithImplicitNonMsiPrimaryPackage() |
| 294 | { |
| 295 | using (var fs = new DisposableFileSystem()) |
| 296 | { |
| 297 | var baseFolder = fs.GetFolder(); |
| 298 | var bundleFile = Path.Combine(baseFolder, "bin", "test.exe"); |
| 299 | var bundleSourceFolder = TestData.Get(@"TestData\WixIuiBa"); |
| 300 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 301 | |
| 302 | var compileResult = WixRunner.Execute(new[] |
| 303 | { |
| 304 | "build", |
| 305 | Path.Combine(bundleSourceFolder, "ImplicitNonMsiPrimaryPackage.wxs"), |
| 306 | "-ext", TestData.Get(@"WixToolset.BootstrapperApplications.wixext.dll"), |
| 307 | "-intermediateFolder", intermediateFolder, |
| 308 | "-bindpath", TestData.Get(@"TestData\WixStdBa\Data"), |
| 309 | "-o", bundleFile, |
| 310 | }); |
| 311 | |
| 312 | WixAssert.CompareLineByLine(new[] |
| 313 | { |
| 314 | "When using WixInternalUIBootstrapperApplication, packages must either be non-permanent and have the bal:PrimaryPackageType attribute, or be permanent and have the bal:PrereqPackage attribute set to 'yes'.", |
| 315 | }, compileResult.Messages.Select(m => m.ToString()).ToArray()); |
| 316 | |
| 317 | Assert.Equal(6811, compileResult.ExitCode); |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | [Fact] |
| 322 | public void CannotBuildUsingWixIuiBaWithImplicitPrimaryPackageEnableFeatureSelection() |
| 323 | { |
| 324 | using (var fs = new DisposableFileSystem()) |
| 325 | { |
| 326 | var baseFolder = fs.GetFolder(); |
| 327 | var bundleFile = Path.Combine(baseFolder, "bin", "test.exe"); |
| 328 | var bundleSourceFolder = TestData.Get(@"TestData\WixIuiBa"); |
| 329 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 330 | |
| 331 | var compileResult = WixRunner.Execute(new[] |
| 332 | { |
| 333 | "build", |
| 334 | Path.Combine(bundleSourceFolder, "ImplicitPrimaryPackageEnableFeatureSelection.wxs"), |
| 335 | "-ext", TestData.Get(@"WixToolset.BootstrapperApplications.wixext.dll"), |
| 336 | "-intermediateFolder", intermediateFolder, |
| 337 | "-bindpath", TestData.Get(@"TestData\WixStdBa\Data"), |
| 338 | "-o", bundleFile, |
| 339 | }); |
| 340 | |
| 341 | WixAssert.CompareLineByLine(new[] |
| 342 | { |
| 343 | "When using WixInternalUIBootstrapperApplication, packages must either be non-permanent and have the bal:PrimaryPackageType attribute, or be permanent and have the bal:PrereqPackage attribute set to 'yes'.", |
| 344 | }, compileResult.Messages.Select(m => m.ToString()).ToArray()); |
| 345 | |
| 346 | Assert.Equal(6811, compileResult.ExitCode); |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | [Fact] |
| 351 | public void CannotBuildUsingWixIuiBaWithMultipleNonPermanentNonPrimaryPackages() |
| 352 | { |
| 353 | using (var fs = new DisposableFileSystem()) |
| 354 | { |
| 355 | var baseFolder = fs.GetFolder(); |
| 356 | var bundleFile = Path.Combine(baseFolder, "bin", "test.exe"); |
| 357 | var bundleSourceFolder = TestData.Get(@"TestData\WixIuiBa"); |
| 358 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 359 | |
| 360 | var compileResult = WixRunner.Execute(new[] |
| 361 | { |
| 362 | "build", |
| 363 | Path.Combine(bundleSourceFolder, "MultipleNonPermanentNonPrimaryPackages.wxs"), |
| 364 | "-ext", TestData.Get(@"WixToolset.BootstrapperApplications.wixext.dll"), |
| 365 | "-intermediateFolder", intermediateFolder, |
| 366 | "-bindpath", TestData.Get(@"TestData\WixStdBa\Data"), |
| 367 | "-o", bundleFile, |
| 368 | }); |
| 369 | |
| 370 | WixAssert.CompareLineByLine(new[] |
| 371 | { |
| 372 | "When using WixInternalUIBootstrapperApplication, packages must either be non-permanent and have the bal:PrimaryPackageType attribute, or be permanent and have the bal:PrereqPackage attribute set to 'yes'.", |
| 373 | "When using WixInternalUIBootstrapperApplication, packages must either be non-permanent and have the bal:PrimaryPackageType attribute, or be permanent and have the bal:PrereqPackage attribute set to 'yes'.", |
| 374 | }, compileResult.Messages.Select(m => m.ToString()).ToArray()); |
| 375 | |
| 376 | Assert.Equal(6811, compileResult.ExitCode); |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | [Fact] |
| 381 | public void CannotBuildUsingWixIuiBaWithMultiplePrimaryPackagesOfSameType() |
| 382 | { |
| 383 | using (var fs = new DisposableFileSystem()) |
| 384 | { |
| 385 | var baseFolder = fs.GetFolder(); |
| 386 | var bundleFile = Path.Combine(baseFolder, "bin", "test.exe"); |
| 387 | var bundleSourceFolder = TestData.Get(@"TestData\WixIuiBa"); |
| 388 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 389 | |
| 390 | var compileResult = WixRunner.Execute(new[] |
| 391 | { |
| 392 | "build", |
| 393 | Path.Combine(bundleSourceFolder, "MultipleDefaultPrimaryPackages.wxs"), |
| 394 | "-ext", TestData.Get(@"WixToolset.BootstrapperApplications.wixext.dll"), |
| 395 | "-intermediateFolder", intermediateFolder, |
| 396 | "-bindpath", TestData.Get(@"TestData\WixStdBa\Data"), |
| 397 | "-o", bundleFile, |
| 398 | }); |
| 399 | |
| 400 | WixAssert.CompareLineByLine(new[] |
| 401 | { |
| 402 | "There may only be one package in the bundle with PrimaryPackageType of 'default'.", |
| 403 | "The location of the package related to the previous error.", |
| 404 | }, compileResult.Messages.Select(m => m.ToString()).ToArray()); |
| 405 | |
| 406 | Assert.Equal(6810, compileResult.ExitCode); |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | [Fact] |
| 411 | public void CannotBuildUsingWixIuiBaWithNoDefaultPrimaryPackage() |
| 412 | { |
| 413 | using (var fs = new DisposableFileSystem()) |
| 414 | { |
| 415 | var baseFolder = fs.GetFolder(); |
| 416 | var bundleFile = Path.Combine(baseFolder, "bin", "test.exe"); |
| 417 | var bundleSourceFolder = TestData.Get(@"TestData\WixIuiBa"); |
| 418 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 419 | |
| 420 | var compileResult = WixRunner.Execute(new[] |
| 421 | { |
| 422 | "build", |
| 423 | Path.Combine(bundleSourceFolder, "NoDefaultPrimaryPackage.wxs"), |
| 424 | "-ext", TestData.Get(@"WixToolset.BootstrapperApplications.wixext.dll"), |
| 425 | "-intermediateFolder", intermediateFolder, |
| 426 | "-bindpath", TestData.Get(@"TestData\WixStdBa\Data"), |
| 427 | "-o", bundleFile, |
| 428 | }); |
| 429 | |
| 430 | WixAssert.CompareLineByLine(new[] |
| 431 | { |
| 432 | "When using WixInternalUIBootstrapperApplication, there must be one package with bal:PrimaryPackageType=\"default\".", |
| 433 | }, compileResult.Messages.Select(m => m.ToString()).ToArray()); |
| 434 | |
| 435 | Assert.Equal(6808, compileResult.ExitCode); |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | [Fact] |
| 440 | public void CannotBuildUsingWixIuiBaWithNonMsiPrimaryPackage() |
| 441 | { |
| 442 | using (var fs = new DisposableFileSystem()) |
| 443 | { |
| 444 | var baseFolder = fs.GetFolder(); |
| 445 | var bundleFile = Path.Combine(baseFolder, "bin", "test.exe"); |
| 446 | var bundleSourceFolder = TestData.Get(@"TestData\WixIuiBa"); |
| 447 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 448 | |
| 449 | var compileResult = WixRunner.Execute(new[] |
| 450 | { |
| 451 | "build", |
| 452 | Path.Combine(bundleSourceFolder, "NonMsiPrimaryPackage.wxs"), |
| 453 | "-ext", TestData.Get(@"WixToolset.BootstrapperApplications.wixext.dll"), |
| 454 | "-intermediateFolder", intermediateFolder, |
| 455 | "-bindpath", TestData.Get(@"TestData\WixStdBa\Data"), |
| 456 | "-o", bundleFile, |
| 457 | }); |
| 458 | |
| 459 | WixAssert.CompareLineByLine(new[] |
| 460 | { |
| 461 | "When using WixInternalUIBootstrapperApplication, each primary package must be an MsiPackage.", |
| 462 | }, compileResult.Messages.Select(m => m.ToString()).ToArray()); |
| 463 | |
| 464 | Assert.Equal(6814, compileResult.ExitCode); |
| 465 | } |
| 466 | } |
| 467 | |
| 468 | [Fact] |
| 469 | public void CannotBuildUsingWixIuiBaWithNonPermanentPrereqPackage() |
| 470 | { |
| 471 | using (var fs = new DisposableFileSystem()) |
| 472 | { |
| 473 | var baseFolder = fs.GetFolder(); |
| 474 | var bundleFile = Path.Combine(baseFolder, "bin", "test.exe"); |
| 475 | var bundleSourceFolder = TestData.Get(@"TestData\WixIuiBa"); |
| 476 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 477 | |
| 478 | var compileResult = WixRunner.Execute(new[] |
| 479 | { |
| 480 | "build", |
| 481 | Path.Combine(bundleSourceFolder, "NonPermanentPrereqPackage.wxs"), |
| 482 | "-ext", TestData.Get(@"WixToolset.BootstrapperApplications.wixext.dll"), |
| 483 | "-intermediateFolder", intermediateFolder, |
| 484 | "-bindpath", TestData.Get(@"TestData\WixStdBa\Data"), |
| 485 | "-o", bundleFile, |
| 486 | }); |
| 487 | |
| 488 | WixAssert.CompareLineByLine(new[] |
| 489 | { |
| 490 | "When using WixInternalUIBootstrapperApplication and bal:PrereqPackage is set to 'yes', the package must be permanent.", |
| 491 | }, compileResult.Messages.Select(m => m.ToString()).ToArray()); |
| 492 | |
| 493 | Assert.Equal(6812, compileResult.ExitCode); |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | [Fact] |
| 498 | public void CannotBuildUsingWixIuiBaWithPermanentPrimaryPackage() |
| 499 | { |
| 500 | using (var fs = new DisposableFileSystem()) |
| 501 | { |
| 502 | var baseFolder = fs.GetFolder(); |
| 503 | var bundleFile = Path.Combine(baseFolder, "bin", "test.exe"); |
| 504 | var bundleSourceFolder = TestData.Get(@"TestData\WixIuiBa"); |
| 505 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 506 | |
| 507 | var compileResult = WixRunner.Execute(new[] |
| 508 | { |
| 509 | "build", |
| 510 | Path.Combine(bundleSourceFolder, "PermanentPrimaryPackage.wxs"), |
| 511 | "-ext", TestData.Get(@"WixToolset.BootstrapperApplications.wixext.dll"), |
| 512 | "-intermediateFolder", intermediateFolder, |
| 513 | "-bindpath", TestData.Get(@"TestData\WixStdBa\Data"), |
| 514 | "-o", bundleFile, |
| 515 | }); |
| 516 | |
| 517 | WixAssert.CompareLineByLine(new[] |
| 518 | { |
| 519 | "When using WixInternalUIBootstrapperApplication, packages with the bal:PrimaryPackageType attribute must not be permanent.", |
| 520 | "When using WixInternalUIBootstrapperApplication, there must be one package with bal:PrimaryPackageType=\"default\".", |
| 521 | }, compileResult.Messages.Select(m => m.ToString()).ToArray()); |
| 522 | |
| 523 | Assert.Equal(6808, compileResult.ExitCode); |
| 524 | } |
| 525 | } |
| 526 | |
| 527 | [Fact] |
| 528 | public void CannotBuildUsingWixIuiBaWithPrimaryPackageEnableFeatureSelection() |
| 529 | { |
| 530 | using (var fs = new DisposableFileSystem()) |
| 531 | { |
| 532 | var baseFolder = fs.GetFolder(); |
| 533 | var bundleFile = Path.Combine(baseFolder, "bin", "test.exe"); |
| 534 | var bundleSourceFolder = TestData.Get(@"TestData\WixIuiBa"); |
| 535 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 536 | |
| 537 | var compileResult = WixRunner.Execute(new[] |
| 538 | { |
| 539 | "build", |
| 540 | Path.Combine(bundleSourceFolder, "PrimaryPackageEnableFeatureSelection.wxs"), |
| 541 | "-ext", TestData.Get(@"WixToolset.BootstrapperApplications.wixext.dll"), |
| 542 | "-intermediateFolder", intermediateFolder, |
| 543 | "-bindpath", TestData.Get(@"TestData\WixStdBa\Data"), |
| 544 | "-o", bundleFile, |
| 545 | }); |
| 546 | |
| 547 | WixAssert.CompareLineByLine(new[] |
| 548 | { |
| 549 | "When using WixInternalUIBootstrapperApplication, primary packages must not have feature selection enabled because it interferes with the user selecting feature through the MSI UI.", |
| 550 | "When using WixInternalUIBootstrapperApplication, there must be one package with bal:PrimaryPackageType=\"default\".", |
| 551 | }, compileResult.Messages.Select(m => m.ToString()).ToArray()); |
| 552 | |
| 553 | Assert.Equal(6808, compileResult.ExitCode); |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | [Fact] |
| 558 | public void CannotBuildUsingWixIuiBaWithPrimaryPrereqPackage() |
| 559 | { |
| 560 | using (var fs = new DisposableFileSystem()) |
| 561 | { |
| 562 | var baseFolder = fs.GetFolder(); |
| 563 | var wixlibFile = Path.Combine(baseFolder, "bin", "test.wixlib"); |
| 564 | var bundleSourceFolder = TestData.Get(@"TestData\WixIuiBa"); |
| 565 | var intermediateFolder = Path.Combine(baseFolder, "obj"); |
| 566 | |
| 567 | var compileResult = WixRunner.Execute(new[] |
| 568 | { |
| 569 | "build", |
| 570 | Path.Combine(bundleSourceFolder, "PrimaryPrereqPackage.wxs"), |
| 571 | "-ext", TestData.Get(@"WixToolset.BootstrapperApplications.wixext.dll"), |
| 572 | "-intermediateFolder", intermediateFolder, |
| 573 | "-o", wixlibFile, |
| 574 | }); |
| 575 | |
| 576 | WixAssert.CompareLineByLine(new[] |
| 577 | { |
| 578 | "The MsiPackage/@PrereqPackage attribute's value, 'yes', cannot be specified with attribute PrimaryPackageType present.", |
| 579 | }, compileResult.Messages.Select(m => m.ToString()).ToArray()); |
| 580 | |
| 581 | Assert.Equal(193, compileResult.ExitCode); |
| 582 | } |
| 583 | } |
| 584 | } |
| 585 | } |