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.cs71
1 files changed, 25 insertions, 46 deletions
diff --git a/src/WixToolset.Core/Librarian.cs b/src/WixToolset.Core/Librarian.cs
index f4191e86..c42356ac 100644
--- a/src/WixToolset.Core/Librarian.cs
+++ b/src/WixToolset.Core/Librarian.cs
@@ -54,39 +54,46 @@ namespace WixToolset.Core
54 extension.PreCombine(this.Context); 54 extension.PreCombine(this.Context);
55 } 55 }
56 56
57 var sections = this.Context.Intermediates.SelectMany(i => i.Sections).ToList(); 57 Intermediate library = null;
58 58 try
59 var embedFilePaths = this.ResolveFilePathsToEmbed(sections); 59 {
60 var sections = this.Context.Intermediates.SelectMany(i => i.Sections).ToList();
60 61
61 var localizationsByCulture = this.CollateLocalizations(this.Context.Localizations); 62 var collate = new CollateLocalizationsCommand(this.Context.Messaging, this.Context.Localizations);
63 var localizationsByCulture = collate.Execute();
62 64
63 if (this.Context.Messaging.EncounteredError) 65 if (this.Context.Messaging.EncounteredError)
64 { 66 {
65 return null; 67 return null;
66 } 68 }
67 69
68 foreach (var section in sections) 70 var embedFilePaths = this.ResolveFilePathsToEmbed(sections);
69 {
70 section.LibraryId = this.Context.LibraryId;
71 }
72 71
73 var library = new Intermediate(this.Context.LibraryId, sections, localizationsByCulture, embedFilePaths); 72 foreach (var section in sections)
73 {
74 section.LibraryId = this.Context.LibraryId;
75 }
74 76
75 this.Validate(library); 77 library = new Intermediate(this.Context.LibraryId, sections, localizationsByCulture, embedFilePaths);
76 78
77 foreach (var extension in this.Context.Extensions) 79 this.Validate(library);
80 }
81 finally
78 { 82 {
79 extension.PostCombine(library); 83 foreach (var extension in this.Context.Extensions)
84 {
85 extension.PostCombine(library);
86 }
80 } 87 }
81 88
82 return library; 89 return this.Context.Messaging.EncounteredError ? null : library;
83 } 90 }
84 91
85 /// <summary> 92 /// <summary>
86 /// Validate that a library contains one entry section and no duplicate symbols. 93 /// Validate that a library contains one entry section and no duplicate symbols.
87 /// </summary> 94 /// </summary>
88 /// <param name="library">Library to validate.</param> 95 /// <param name="library">Library to validate.</param>
89 private Intermediate Validate(Intermediate library) 96 private void Validate(Intermediate library)
90 { 97 {
91 FindEntrySectionAndLoadSymbolsCommand find = new FindEntrySectionAndLoadSymbolsCommand(this.Context.Messaging, library.Sections); 98 FindEntrySectionAndLoadSymbolsCommand find = new FindEntrySectionAndLoadSymbolsCommand(this.Context.Messaging, library.Sections);
92 find.Execute(); 99 find.Execute();
@@ -100,34 +107,6 @@ namespace WixToolset.Core
100 // ReportDuplicateResolvedSymbolErrorsCommand reportDupes = new ReportDuplicateResolvedSymbolErrorsCommand(find.SymbolsWithDuplicates, resolve.ResolvedSections); 107 // ReportDuplicateResolvedSymbolErrorsCommand reportDupes = new ReportDuplicateResolvedSymbolErrorsCommand(find.SymbolsWithDuplicates, resolve.ResolvedSections);
101 // reportDupes.Execute(); 108 // reportDupes.Execute();
102 // } 109 // }
103
104 return (this.Context.Messaging.EncounteredError ? null : library);
105 }
106
107 private Dictionary<string, Localization> CollateLocalizations(IEnumerable<Localization> localizations)
108 {
109 var localizationsByCulture = new Dictionary<string, Localization>(StringComparer.OrdinalIgnoreCase);
110
111 foreach (var localization in localizations)
112 {
113 if (localizationsByCulture.TryGetValue(localization.Culture, out var existingCulture))
114 {
115 try
116 {
117 existingCulture.Merge(localization);
118 }
119 catch (WixException e)
120 {
121 this.Context.Messaging.Write(e.Error);
122 }
123 }
124 else
125 {
126 localizationsByCulture.Add(localization.Culture, localization);
127 }
128 }
129
130 return localizationsByCulture;
131 } 110 }
132 111
133 private List<string> ResolveFilePathsToEmbed(IEnumerable<IntermediateSection> sections) 112 private List<string> ResolveFilePathsToEmbed(IEnumerable<IntermediateSection> sections)