diff options
| author | Rob Mensching <rob@firegiant.com> | 2019-01-01 00:26:30 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@robmensching.com> | 2019-01-01 09:58:27 -0800 |
| commit | 41622a07f82c57cf3d80393b0b6914f5ccb76e33 (patch) | |
| tree | 8b42a4903f4a98161b44049dd7f73721de6011b0 /src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs | |
| parent | e8cb78045d7d03b5014e1e6d781b71165db9b17d (diff) | |
| download | wix-41622a07f82c57cf3d80393b0b6914f5ccb76e33.tar.gz wix-41622a07f82c57cf3d80393b0b6914f5ccb76e33.tar.bz2 wix-41622a07f82c57cf3d80393b0b6914f5ccb76e33.zip | |
Load .wixlib intermediates with single creator
Using a single creator ensures definitions are shared and consistent
across the entire build.
Diffstat (limited to 'src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs')
| -rw-r--r-- | src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs b/src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs new file mode 100644 index 00000000..532f158d --- /dev/null +++ b/src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs | |||
| @@ -0,0 +1,173 @@ | |||
| 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.CoreIntegration | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.IO; | ||
| 7 | using System.Linq; | ||
| 8 | using Example.Extension; | ||
| 9 | using WixBuildTools.TestSupport; | ||
| 10 | using WixToolset.Core.TestPackage; | ||
| 11 | using WixToolset.Data; | ||
| 12 | using WixToolset.Data.Tuples; | ||
| 13 | using Xunit; | ||
| 14 | |||
| 15 | public class WixlibFixture | ||
| 16 | { | ||
| 17 | [Fact] | ||
| 18 | public void CanBuildSingleFileUsingWixlib() | ||
| 19 | { | ||
| 20 | var folder = TestData.Get(@"TestData\SingleFile"); | ||
| 21 | |||
| 22 | using (var fs = new DisposableFileSystem()) | ||
| 23 | { | ||
| 24 | var baseFolder = fs.GetFolder(); | ||
| 25 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
| 26 | |||
| 27 | var result = WixRunner.Execute(new[] | ||
| 28 | { | ||
| 29 | "build", | ||
| 30 | Path.Combine(folder, "PackageComponents.wxs"), | ||
| 31 | "-intermediateFolder", intermediateFolder, | ||
| 32 | "-o", Path.Combine(intermediateFolder, @"test.wixlib") | ||
| 33 | }); | ||
| 34 | |||
| 35 | result.AssertSuccess(); | ||
| 36 | |||
| 37 | result = WixRunner.Execute(new[] | ||
| 38 | { | ||
| 39 | "build", | ||
| 40 | Path.Combine(folder, "Package.wxs"), | ||
| 41 | "-loc", Path.Combine(folder, "Package.en-us.wxl"), | ||
| 42 | "-lib", Path.Combine(intermediateFolder, @"test.wixlib"), | ||
| 43 | "-bindpath", Path.Combine(folder, "data"), | ||
| 44 | "-intermediateFolder", intermediateFolder, | ||
| 45 | "-o", Path.Combine(baseFolder, @"bin\test.msi") | ||
| 46 | }); | ||
| 47 | |||
| 48 | result.AssertSuccess(); | ||
| 49 | |||
| 50 | var intermediate = Intermediate.Load(Path.Combine(baseFolder, @"obj\test.wir")); | ||
| 51 | var section = intermediate.Sections.Single(); | ||
| 52 | |||
| 53 | var wixFile = section.Tuples.OfType<WixFileTuple>().Single(); | ||
| 54 | Assert.Equal(Path.Combine(folder, @"data\test.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path); | ||
| 55 | Assert.Equal(@"test.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path); | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 59 | [Fact] | ||
| 60 | public void CanBuildWithExtensionUsingWixlib() | ||
| 61 | { | ||
| 62 | var folder = TestData.Get(@"TestData\ExampleExtension"); | ||
| 63 | var extensionPath = Path.GetFullPath(new Uri(typeof(ExampleExtensionFactory).Assembly.CodeBase).LocalPath); | ||
| 64 | |||
| 65 | using (var fs = new DisposableFileSystem()) | ||
| 66 | { | ||
| 67 | var baseFolder = fs.GetFolder(); | ||
| 68 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
| 69 | |||
| 70 | var result = WixRunner.Execute(new[] | ||
| 71 | { | ||
| 72 | "build", | ||
| 73 | Path.Combine(folder, "PackageComponents.wxs"), | ||
| 74 | "-ext", extensionPath, | ||
| 75 | "-intermediateFolder", intermediateFolder, | ||
| 76 | "-o", Path.Combine(intermediateFolder, @"test.wixlib") | ||
| 77 | }); | ||
| 78 | |||
| 79 | result.AssertSuccess(); | ||
| 80 | |||
| 81 | result = WixRunner.Execute(new[] | ||
| 82 | { | ||
| 83 | "build", | ||
| 84 | Path.Combine(folder, "Package.wxs"), | ||
| 85 | "-loc", Path.Combine(folder, "Package.en-us.wxl"), | ||
| 86 | "-lib", Path.Combine(intermediateFolder, @"test.wixlib"), | ||
| 87 | "-ext", extensionPath, | ||
| 88 | "-bindpath", Path.Combine(folder, "data"), | ||
| 89 | "-intermediateFolder", intermediateFolder, | ||
| 90 | "-o", Path.Combine(intermediateFolder, @"bin\test.msi") | ||
| 91 | }); | ||
| 92 | |||
| 93 | result.AssertSuccess(); | ||
| 94 | |||
| 95 | var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"test.wir")); | ||
| 96 | var section = intermediate.Sections.Single(); | ||
| 97 | |||
| 98 | var wixFile = section.Tuples.OfType<WixFileTuple>().Single(); | ||
| 99 | Assert.Equal(Path.Combine(folder, @"data\example.txt"), wixFile[WixFileTupleFields.Source].AsPath().Path); | ||
| 100 | Assert.Equal(@"example.txt", wixFile[WixFileTupleFields.Source].PreviousValue.AsPath().Path); | ||
| 101 | |||
| 102 | var example = section.Tuples.Where(t => t.Definition.Type == TupleDefinitionType.MustBeFromAnExtension).Single(); | ||
| 103 | Assert.Equal("Foo", example.Id.Id); | ||
| 104 | Assert.Equal("Foo", example[0].AsString()); | ||
| 105 | Assert.Equal("Bar", example[1].AsString()); | ||
| 106 | } | ||
| 107 | } | ||
| 108 | |||
| 109 | [Fact] | ||
| 110 | public void CanBuildWithExtensionUsingMultipleWixlibs() | ||
| 111 | { | ||
| 112 | var folder = TestData.Get(@"TestData\ComplexExampleExtension"); | ||
| 113 | var extensionPath = Path.GetFullPath(new Uri(typeof(ExampleExtensionFactory).Assembly.CodeBase).LocalPath); | ||
| 114 | |||
| 115 | using (var fs = new DisposableFileSystem()) | ||
| 116 | { | ||
| 117 | var baseFolder = fs.GetFolder(); | ||
| 118 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
| 119 | |||
| 120 | var result = WixRunner.Execute(new[] | ||
| 121 | { | ||
| 122 | "build", | ||
| 123 | Path.Combine(folder, "PackageComponents.wxs"), | ||
| 124 | "-ext", extensionPath, | ||
| 125 | "-intermediateFolder", intermediateFolder, | ||
| 126 | "-o", Path.Combine(intermediateFolder, @"components.wixlib") | ||
| 127 | }); | ||
| 128 | |||
| 129 | result.AssertSuccess(); | ||
| 130 | |||
| 131 | result = WixRunner.Execute(new[] | ||
| 132 | { | ||
| 133 | "build", | ||
| 134 | Path.Combine(folder, "OtherComponents.wxs"), | ||
| 135 | "-ext", extensionPath, | ||
| 136 | "-intermediateFolder", intermediateFolder, | ||
| 137 | "-o", Path.Combine(intermediateFolder, @"other.wixlib") | ||
| 138 | }); | ||
| 139 | |||
| 140 | result.AssertSuccess(); | ||
| 141 | |||
| 142 | result = WixRunner.Execute(new[] | ||
| 143 | { | ||
| 144 | "build", | ||
| 145 | Path.Combine(folder, "Package.wxs"), | ||
| 146 | "-loc", Path.Combine(folder, "Package.en-us.wxl"), | ||
| 147 | "-lib", Path.Combine(intermediateFolder, @"components.wixlib"), | ||
| 148 | "-lib", Path.Combine(intermediateFolder, @"other.wixlib"), | ||
| 149 | "-ext", extensionPath, | ||
| 150 | "-bindpath", Path.Combine(folder, "data"), | ||
| 151 | "-intermediateFolder", intermediateFolder, | ||
| 152 | "-o", Path.Combine(intermediateFolder, @"bin\test.msi") | ||
| 153 | }); | ||
| 154 | |||
| 155 | result.AssertSuccess(); | ||
| 156 | |||
| 157 | var intermediate = Intermediate.Load(Path.Combine(intermediateFolder, @"test.wir")); | ||
| 158 | var section = intermediate.Sections.Single(); | ||
| 159 | |||
| 160 | var wixFiles = section.Tuples.OfType<WixFileTuple>().OrderBy(t => Path.GetFileName(t.Source.Path)).ToArray(); | ||
| 161 | Assert.Equal(Path.Combine(folder, @"data\example.txt"), wixFiles[0][WixFileTupleFields.Source].AsPath().Path); | ||
| 162 | Assert.Equal(@"example.txt", wixFiles[0][WixFileTupleFields.Source].PreviousValue.AsPath().Path); | ||
| 163 | Assert.Equal(Path.Combine(folder, @"data\other.txt"), wixFiles[1][WixFileTupleFields.Source].AsPath().Path); | ||
| 164 | Assert.Equal(@"other.txt", wixFiles[1][WixFileTupleFields.Source].PreviousValue.AsPath().Path); | ||
| 165 | |||
| 166 | var examples = section.Tuples.Where(t => t.Definition.Type == TupleDefinitionType.MustBeFromAnExtension).ToArray(); | ||
| 167 | Assert.Equal(new[] { "Foo", "Other" }, examples.Select(t => t.Id.Id).ToArray()); | ||
| 168 | Assert.Equal(new[] { "Foo", "Other" }, examples.Select(t => t.AsString(0)).ToArray()); | ||
| 169 | Assert.Equal(new[] { "Bar", "Value" }, examples.Select(t => t[1].AsString()).ToArray()); | ||
| 170 | } | ||
| 171 | } | ||
| 172 | } | ||
| 173 | } | ||
