aboutsummaryrefslogtreecommitdiff
path: root/src/wix/test/WixToolsetTest.CoreIntegration/VersionFixture.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/wix/test/WixToolsetTest.CoreIntegration/VersionFixture.cs')
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/VersionFixture.cs94
1 files changed, 94 insertions, 0 deletions
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/VersionFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/VersionFixture.cs
new file mode 100644
index 00000000..c3758c7e
--- /dev/null
+++ b/src/wix/test/WixToolsetTest.CoreIntegration/VersionFixture.cs
@@ -0,0 +1,94 @@
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
3namespace WixToolsetTest.CoreIntegration
4{
5 using System.IO;
6 using System.Linq;
7 using System.Xml;
8 using WixBuildTools.TestSupport;
9 using WixToolset.Core.TestPackage;
10 using WixToolset.Data;
11 using Xunit;
12
13 public class VersionFixture
14 {
15 [Fact]
16 public void CannotBuildMsiWithInvalidMajorVersion()
17 {
18 var folder = TestData.Get(@"TestData");
19
20 using (var fs = new DisposableFileSystem())
21 {
22 var baseFolder = fs.GetFolder();
23 var intermediateFolder = Path.Combine(baseFolder, "obj");
24 var msiPath = Path.Combine(baseFolder, @"bin\test1.msi");
25
26 var result = WixRunner.Execute(new[]
27 {
28 "build",
29 Path.Combine(folder, "Version", "Package.wxs"),
30 "-bindpath", Path.Combine(folder, "SingleFile", "data"),
31 "-intermediateFolder", intermediateFolder,
32 "-d", "Version=257.0.0",
33 "-o", msiPath
34 });
35
36 var message = result.Messages.Single(m => m.Level == MessageLevel.Error);
37 Assert.Equal("Invalid product version '257.0.0'. Product version must have a major version less than 256, a minor version less than 256, and a build version less than 65536.", message.ToString());
38 Assert.Equal(242, result.ExitCode);
39 }
40 }
41
42 [Fact]
43 public void CanBuildBundleWithSemanticVersion()
44 {
45 var folder = TestData.Get(@"TestData");
46
47 using (var fs = new DisposableFileSystem())
48 {
49 var baseFolder = fs.GetFolder();
50 var intermediateFolder = Path.Combine(baseFolder, "obj");
51 var msiPath = Path.Combine(baseFolder, @"bin\test1.msi");
52 var msi2Path = Path.Combine(baseFolder, @"bin\test2.msi");
53 var bundlePath = Path.Combine(baseFolder, @"bin\bundle.exe");
54
55 var result = WixRunner.Execute(new[]
56 {
57 "build",
58 Path.Combine(folder, "Version", "Package.wxs"),
59 "-bindpath", Path.Combine(folder, "SingleFile", "data"),
60 "-intermediateFolder", intermediateFolder,
61 "-d", "Version=255.255.65535",
62 "-o", msiPath
63 });
64
65 result.AssertSuccess();
66
67 var result3 = WixRunner.Execute(new[]
68{
69 "build",
70 Path.Combine(folder, "Version", "Bundle.wxs"),
71 "-bindpath", Path.Combine(folder, "SimpleBundle", "data"),
72 "-bindpath", Path.Combine(baseFolder, "bin"),
73 "-intermediateFolder", intermediateFolder,
74 "-d", "Version=2022.3.9-preview.0-build.5+0987654321abcdef1234567890",
75 "-o", bundlePath
76 });
77
78 result3.AssertSuccess();
79
80 var propertyTable = Query.QueryDatabase(msiPath, new[] { "Property" }).Select(r => r.Split('\t')).ToDictionary(r => r[0].Substring("Property:".Length), r => r[1]);
81 Assert.True(propertyTable.TryGetValue("ProductVersion", out var productVersion));
82 Assert.Equal("255.255.65535", productVersion);
83
84 var extractResult = BundleExtractor.ExtractAllContainers(null, bundlePath, Path.Combine(baseFolder, "ba"), Path.Combine(baseFolder, "attached"), Path.Combine(baseFolder, "extract"));
85 extractResult.AssertSuccess();
86
87 var bundleVersion = extractResult.SelectManifestNodes("/burn:BurnManifest/burn:Registration/@Version")
88 .Cast<XmlAttribute>()
89 .Single();
90 Assert.Equal("2022.3.9-preview.0-build.5+0987654321abcdef1234567890", bundleVersion.Value);
91 }
92 }
93 }
94}