aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core/Librarian.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core/Librarian.cs')
-rw-r--r--src/WixToolset.Core/Librarian.cs43
1 files changed, 34 insertions, 9 deletions
diff --git a/src/WixToolset.Core/Librarian.cs b/src/WixToolset.Core/Librarian.cs
index 66a8c32d..092d81dc 100644
--- a/src/WixToolset.Core/Librarian.cs
+++ b/src/WixToolset.Core/Librarian.cs
@@ -1,10 +1,11 @@
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 3namespace WixToolset.Core
4{ 4{
5 using System; 5 using System;
6 using System.Collections.Generic; 6 using System.Collections.Generic;
7 using System.Linq; 7 using System.Linq;
8 using WixToolset.Core.Bind;
8 using WixToolset.Data; 9 using WixToolset.Data;
9 using WixToolset.Link; 10 using WixToolset.Link;
10 11
@@ -13,20 +14,41 @@ namespace WixToolset
13 /// </summary> 14 /// </summary>
14 public sealed class Librarian 15 public sealed class Librarian
15 { 16 {
17 public Librarian(LibraryContext context)
18 {
19 this.Context = context;
20 }
21
22 private LibraryContext Context { get; }
23
16 /// <summary> 24 /// <summary>
17 /// Create a library by combining several intermediates (objects). 25 /// Create a library by combining several intermediates (objects).
18 /// </summary> 26 /// </summary>
19 /// <param name="sections">The sections to combine into a library.</param> 27 /// <param name="sections">The sections to combine into a library.</param>
20 /// <returns>Returns the new library.</returns> 28 /// <returns>Returns the new library.</returns>
21 public Library Combine(IEnumerable<Section> sections, IEnumerable<Localization> localizations, ILibraryBinaryFileResolver resolver) 29 public Library Combine()
22 { 30 {
23 var localizationsByCulture = CollateLocalizations(localizations); 31 foreach (var extension in this.Context.Extensions)
32 {
33 extension.PreCombine(this.Context);
34 }
35
36 var fileResolver = new FileResolver(this.Context.BindPaths, this.Context.Extensions);
24 37
25 var embedFilePaths = ResolveFilePathsToEmbed(sections, resolver); 38 var localizationsByCulture = CollateLocalizations(this.Context.Localizations);
26 39
27 var library = new Library(sections, localizationsByCulture, embedFilePaths); 40 var embedFilePaths = ResolveFilePathsToEmbed(this.Context.Sections, fileResolver);
28 41
29 return this.Validate(library); 42 var library = new Library(this.Context.Sections, localizationsByCulture, embedFilePaths);
43
44 this.Validate(library);
45
46 foreach (var extension in this.Context.Extensions)
47 {
48 extension.PostCombine(library);
49 }
50
51 return library;
30 } 52 }
31 53
32 /// <summary> 54 /// <summary>
@@ -70,12 +92,12 @@ namespace WixToolset
70 return localizationsByCulture; 92 return localizationsByCulture;
71 } 93 }
72 94
73 private static List<string> ResolveFilePathsToEmbed(IEnumerable<Section> sections, ILibraryBinaryFileResolver resolver) 95 private List<string> ResolveFilePathsToEmbed(IEnumerable<Section> sections, FileResolver fileResolver)
74 { 96 {
75 var embedFilePaths = new List<string>(); 97 var embedFilePaths = new List<string>();
76 98
77 // Resolve paths to files that are to be embedded in the library. 99 // Resolve paths to files that are to be embedded in the library.
78 if (null != resolver) 100 if (this.Context.BindFiles)
79 { 101 {
80 foreach (Table table in sections.SelectMany(s => s.Tables)) 102 foreach (Table table in sections.SelectMany(s => s.Tables))
81 { 103 {
@@ -85,7 +107,10 @@ namespace WixToolset
85 { 107 {
86 if (null != objectField.Data) 108 if (null != objectField.Data)
87 { 109 {
88 string file = resolver.Resolve(row.SourceLineNumbers, table.Name, (string)objectField.Data); 110 string resolvedPath = this.Context.WixVariableResolver.ResolveVariables(row.SourceLineNumbers, (string)objectField.Data, false);
111
112 string file = fileResolver.Resolve(row.SourceLineNumbers, table.Name, resolvedPath);
113
89 if (!String.IsNullOrEmpty(file)) 114 if (!String.IsNullOrEmpty(file))
90 { 115 {
91 // File was successfully resolved so track the embedded index as the embedded file index. 116 // File was successfully resolved so track the embedded index as the embedded file index.