aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/WixToolset.Core/CommandLine/BuildCommand.cs31
-rw-r--r--src/WixToolset.Core/ExtensibilityServices/TupleDefinitionCreator.cs7
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/OtherComponents.wxs12
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/Package.en-us.wxl11
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/Package.wxs26
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/PackageComponents.wxs12
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/data/example.txt1
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/data/other.txt1
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj6
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/WixlibFixture.cs173
10 files changed, 259 insertions, 21 deletions
diff --git a/src/WixToolset.Core/CommandLine/BuildCommand.cs b/src/WixToolset.Core/CommandLine/BuildCommand.cs
index 87a3cd30..f754c876 100644
--- a/src/WixToolset.Core/CommandLine/BuildCommand.cs
+++ b/src/WixToolset.Core/CommandLine/BuildCommand.cs
@@ -331,27 +331,20 @@ namespace WixToolset.Core.CommandLine
331 331
332 private IEnumerable<Intermediate> LoadLibraries(IEnumerable<string> libraryFiles, ITupleDefinitionCreator creator) 332 private IEnumerable<Intermediate> LoadLibraries(IEnumerable<string> libraryFiles, ITupleDefinitionCreator creator)
333 { 333 {
334 var libraries = new List<Intermediate>(); 334 try
335
336 foreach (var libraryFile in libraryFiles)
337 { 335 {
338 try 336 return Intermediate.Load(libraryFiles, creator);
339 { 337 }
340 var library = Intermediate.Load(libraryFile, creator); 338 catch (WixCorruptFileException e)
341 339 {
342 libraries.Add(library); 340 this.Messaging.Write(e.Error);
343 } 341 }
344 catch (WixCorruptFileException e) 342 catch (WixUnexpectedFileFormatException e)
345 { 343 {
346 this.Messaging.Write(e.Error); 344 this.Messaging.Write(e.Error);
347 }
348 catch (WixUnexpectedFileFormatException e)
349 {
350 this.Messaging.Write(e.Error);
351 }
352 } 345 }
353 346
354 return libraries; 347 return Array.Empty<Intermediate>();
355 } 348 }
356 349
357 private IEnumerable<Localization> LoadLocalizationFiles(IEnumerable<string> locFiles, IDictionary<string, string> preprocessorVariables) 350 private IEnumerable<Localization> LoadLocalizationFiles(IEnumerable<string> locFiles, IDictionary<string, string> preprocessorVariables)
@@ -437,7 +430,7 @@ namespace WixToolset.Core.CommandLine
437 public string OutputsFile { get; private set; } 430 public string OutputsFile { get; private set; }
438 431
439 public string BuiltOutputsFile { get; private set; } 432 public string BuiltOutputsFile { get; private set; }
440 433
441 public CommandLine(IMessaging messaging) 434 public CommandLine(IMessaging messaging)
442 { 435 {
443 this.Messaging = messaging; 436 this.Messaging = messaging;
diff --git a/src/WixToolset.Core/ExtensibilityServices/TupleDefinitionCreator.cs b/src/WixToolset.Core/ExtensibilityServices/TupleDefinitionCreator.cs
index b442da2b..e223e3a4 100644
--- a/src/WixToolset.Core/ExtensibilityServices/TupleDefinitionCreator.cs
+++ b/src/WixToolset.Core/ExtensibilityServices/TupleDefinitionCreator.cs
@@ -1,4 +1,4 @@
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. 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 2
3namespace WixToolset.Core.ExtensibilityServices 3namespace WixToolset.Core.ExtensibilityServices
4{ 4{
@@ -23,7 +23,10 @@ namespace WixToolset.Core.ExtensibilityServices
23 23
24 public void AddCustomTupleDefinition(IntermediateTupleDefinition definition) 24 public void AddCustomTupleDefinition(IntermediateTupleDefinition definition)
25 { 25 {
26 this.CustomDefinitionByName.Add(definition.Name, definition); 26 if (!this.CustomDefinitionByName.TryGetValue(definition.Name, out var existing) || definition.Revision > existing.Revision)
27 {
28 this.CustomDefinitionByName[definition.Name] = definition;
29 }
27 } 30 }
28 31
29 public bool TryGetTupleDefinitionByName(string name, out IntermediateTupleDefinition tupleDefinition) 32 public bool TryGetTupleDefinitionByName(string name, out IntermediateTupleDefinition tupleDefinition)
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/OtherComponents.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/OtherComponents.wxs
new file mode 100644
index 00000000..15a9a0ce
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/OtherComponents.wxs
@@ -0,0 +1,12 @@
1<?xml version="1.0" encoding="utf-8"?>
2<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
3 xmlns:ex="http://www.example.com/scheams/v1/wxs">
4 <Fragment>
5 <ComponentGroup Id="OtherComponents" Directory="INSTALLFOLDER">
6 <Component>
7 <File Source="other.txt" />
8 <ex:Example Id="Other" Value="Value" />
9 </Component>
10 </ComponentGroup>
11 </Fragment>
12</Wix>
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/Package.en-us.wxl b/src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/Package.en-us.wxl
new file mode 100644
index 00000000..38c12ac1
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/Package.en-us.wxl
@@ -0,0 +1,11 @@
1<?xml version="1.0" encoding="utf-8"?>
2
3<!--
4This file contains the declaration of all the localizable strings.
5-->
6<WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US">
7
8 <String Id="DowngradeError">A newer version of [ProductName] is already installed.</String>
9 <String Id="FeatureTitle">MsiPackage</String>
10
11</WixLocalization>
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/Package.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/Package.wxs
new file mode 100644
index 00000000..0e8e9795
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/Package.wxs
@@ -0,0 +1,26 @@
1<?xml version="1.0" encoding="utf-8"?>
2<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3 <Product Id="*" Name="MsiPackage" Language="1033" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
4 <Package InstallerVersion="200" Compressed="no" InstallScope="perMachine" />
5
6 <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />
7 <MediaTemplate />
8
9 <Property Id="ExampleProperty" Value="$(ex.Test)" />
10
11 <PropertyRef Id="PropertyFromExampleWir" />
12
13 <Feature Id="ProductFeature" Title="!(loc.FeatureTitle)">
14 <ComponentGroupRef Id="ProductComponents" />
15 <ComponentGroupRef Id="OtherComponents" />
16 </Feature>
17 </Product>
18
19 <Fragment>
20 <Directory Id="TARGETDIR" Name="SourceDir">
21 <Directory Id="ProgramFilesFolder">
22 <Directory Id="INSTALLFOLDER" Name="MsiPackage" />
23 </Directory>
24 </Directory>
25 </Fragment>
26</Wix>
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/PackageComponents.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/PackageComponents.wxs
new file mode 100644
index 00000000..7f17b538
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/PackageComponents.wxs
@@ -0,0 +1,12 @@
1<?xml version="1.0" encoding="utf-8"?>
2<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
3 xmlns:ex="http://www.example.com/scheams/v1/wxs">
4 <Fragment>
5 <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
6 <Component>
7 <File Source="example.txt" />
8 <ex:Example Id="Foo" Value="Bar" />
9 </Component>
10 </ComponentGroup>
11 </Fragment>
12</Wix>
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/data/example.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/data/example.txt
new file mode 100644
index 00000000..1b4ffe8a
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/data/example.txt
@@ -0,0 +1 @@
This is example.txt. \ No newline at end of file
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/data/other.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/data/other.txt
new file mode 100644
index 00000000..8c874ae7
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/ComplexExampleExtension/data/other.txt
@@ -0,0 +1 @@
This is other.txt. \ No newline at end of file
diff --git a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj
index 2a20fcff..53c5ceea 100644
--- a/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj
+++ b/src/test/WixToolsetTest.CoreIntegration/WixToolsetTest.CoreIntegration.csproj
@@ -38,6 +38,12 @@
38 <Content Include="TestData\BadIf\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" /> 38 <Content Include="TestData\BadIf\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" />
39 <Content Include="TestData\BadIf\Package.wxs" CopyToOutputDirectory="PreserveNewest" /> 39 <Content Include="TestData\BadIf\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
40 <Content Include="TestData\BadIf\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" /> 40 <Content Include="TestData\BadIf\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" />
41 <Content Include="TestData\ComplexExampleExtension\data\example.txt" CopyToOutputDirectory="PreserveNewest" />
42 <Content Include="TestData\ComplexExampleExtension\data\other.txt" CopyToOutputDirectory="PreserveNewest" />
43 <Content Include="TestData\ComplexExampleExtension\OtherComponents.wxs" CopyToOutputDirectory="PreserveNewest" />
44 <Content Include="TestData\ComplexExampleExtension\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" />
45 <Content Include="TestData\ComplexExampleExtension\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
46 <Content Include="TestData\ComplexExampleExtension\PackageComponents.wxs" CopyToOutputDirectory="PreserveNewest" />
41 <Content Include="TestData\SingleFile\data\test.txt" CopyToOutputDirectory="PreserveNewest" /> 47 <Content Include="TestData\SingleFile\data\test.txt" CopyToOutputDirectory="PreserveNewest" />
42 <Content Include="TestData\SingleFile\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" /> 48 <Content Include="TestData\SingleFile\Package.en-us.wxl" CopyToOutputDirectory="PreserveNewest" />
43 <Content Include="TestData\SingleFile\Package.wxs" CopyToOutputDirectory="PreserveNewest" /> 49 <Content Include="TestData\SingleFile\Package.wxs" CopyToOutputDirectory="PreserveNewest" />
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
3namespace 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}