From c5190ae74ab8fe13609362efce88fa4b8cc24f34 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 30 Dec 2017 17:09:15 -0800 Subject: Fix resolution of localizations that are embedded in intermediates --- src/WixToolset.Core/Librarian.cs | 71 ++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 46 deletions(-) (limited to 'src/WixToolset.Core/Librarian.cs') 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 extension.PreCombine(this.Context); } - var sections = this.Context.Intermediates.SelectMany(i => i.Sections).ToList(); - - var embedFilePaths = this.ResolveFilePathsToEmbed(sections); + Intermediate library = null; + try + { + var sections = this.Context.Intermediates.SelectMany(i => i.Sections).ToList(); - var localizationsByCulture = this.CollateLocalizations(this.Context.Localizations); + var collate = new CollateLocalizationsCommand(this.Context.Messaging, this.Context.Localizations); + var localizationsByCulture = collate.Execute(); - if (this.Context.Messaging.EncounteredError) - { - return null; - } + if (this.Context.Messaging.EncounteredError) + { + return null; + } - foreach (var section in sections) - { - section.LibraryId = this.Context.LibraryId; - } + var embedFilePaths = this.ResolveFilePathsToEmbed(sections); - var library = new Intermediate(this.Context.LibraryId, sections, localizationsByCulture, embedFilePaths); + foreach (var section in sections) + { + section.LibraryId = this.Context.LibraryId; + } - this.Validate(library); + library = new Intermediate(this.Context.LibraryId, sections, localizationsByCulture, embedFilePaths); - foreach (var extension in this.Context.Extensions) + this.Validate(library); + } + finally { - extension.PostCombine(library); + foreach (var extension in this.Context.Extensions) + { + extension.PostCombine(library); + } } - return library; + return this.Context.Messaging.EncounteredError ? null : library; } /// /// Validate that a library contains one entry section and no duplicate symbols. /// /// Library to validate. - private Intermediate Validate(Intermediate library) + private void Validate(Intermediate library) { FindEntrySectionAndLoadSymbolsCommand find = new FindEntrySectionAndLoadSymbolsCommand(this.Context.Messaging, library.Sections); find.Execute(); @@ -100,34 +107,6 @@ namespace WixToolset.Core // ReportDuplicateResolvedSymbolErrorsCommand reportDupes = new ReportDuplicateResolvedSymbolErrorsCommand(find.SymbolsWithDuplicates, resolve.ResolvedSections); // reportDupes.Execute(); // } - - return (this.Context.Messaging.EncounteredError ? null : library); - } - - private Dictionary CollateLocalizations(IEnumerable localizations) - { - var localizationsByCulture = new Dictionary(StringComparer.OrdinalIgnoreCase); - - foreach (var localization in localizations) - { - if (localizationsByCulture.TryGetValue(localization.Culture, out var existingCulture)) - { - try - { - existingCulture.Merge(localization); - } - catch (WixException e) - { - this.Context.Messaging.Write(e.Error); - } - } - else - { - localizationsByCulture.Add(localization.Culture, localization); - } - } - - return localizationsByCulture; } private List ResolveFilePathsToEmbed(IEnumerable sections) -- cgit v1.2.3-55-g6feb