Ejemplo n.º 1
0
        private void LibraryPhase(IEnumerable <Intermediate> intermediates, TableDefinitionCollection tableDefinitions)
        {
            var localizations = this.LoadLocalizationFiles(tableDefinitions).ToList();

            // If there was an error adding localization files, then bail.
            if (Messaging.Instance.EncounteredError)
            {
                return;
            }

            var sections = intermediates.SelectMany(i => i.Sections).ToList();

            LibraryBinaryFileResolver resolver = null;

            if (this.BindFiles)
            {
                resolver = new LibraryBinaryFileResolver();
                resolver.FileManagers = new List <IBinderFileManager> {
                    new BinderFileManager()
                };;
                resolver.VariableResolver = new WixVariableResolver();

                BinderFileManagerCore core = new BinderFileManagerCore();
                core.AddBindPaths(this.BindPaths, BindStage.Normal);

                foreach (var fileManager in resolver.FileManagers)
                {
                    fileManager.Core = core;
                }
            }

            var librarian = new Librarian();

            var library = librarian.Combine(sections, localizations, resolver);

            library?.Save(this.OutputPath);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create the library.
        /// </summary>
        private void Run()
        {
            // Create the librarian and add the extension data.
            Librarian librarian = new Librarian();

            foreach (IExtensionData data in this.extensionData)
            {
                librarian.AddExtensionData(data);
            }

            // Add the sections to the librarian
            SectionCollection sections = new SectionCollection();

            foreach (string file in this.commandLine.Files)
            {
                string inputFile = Path.GetFullPath(file);

                // try loading as an object file
                try
                {
                    Intermediate intermediate = Intermediate.Load(inputFile, librarian.TableDefinitions, this.commandLine.SuppressVersionCheck, true);
                    sections.AddRange(intermediate.Sections);
                    continue; // next file
                }
                catch (WixNotIntermediateException)
                {
                    // try another format
                }

                // try loading as a library file
                Library loadedLibrary = Library.Load(inputFile, librarian.TableDefinitions, this.commandLine.SuppressVersionCheck, true);
                sections.AddRange(loadedLibrary.Sections);
            }

            // and now for the fun part
            Library library = librarian.Combine(sections);

            // Save the library output if an error did not occur
            if (null != library)
            {
                foreach (string localizationFile in this.commandLine.LocalizationFiles)
                {
                    Localization localization = Localization.Load(localizationFile, librarian.TableDefinitions, true);
                    library.AddLocalization(localization);
                }

                LibraryBinaryFileResolver resolver = null;
                if (this.commandLine.BindFiles)
                {
                    resolver = new LibraryBinaryFileResolver();
                    resolver.FileManagers     = this.fileManagers;
                    resolver.VariableResolver = new WixVariableResolver();

                    BinderFileManagerCore core = new BinderFileManagerCore();
                    core.AddBindPaths(this.commandLine.BindPaths, BindStage.Normal);

                    foreach (IBinderFileManager fm in resolver.FileManagers)
                    {
                        fm.Core = core;
                    }
                }

                library.Save(this.commandLine.OutputFile, resolver);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create the library.
        /// </summary>
        private void Run()
        {
            // Create the librarian and add the extension data.
            Librarian librarian = new Librarian();

            foreach (IExtensionData data in this.extensionData)
            {
                librarian.AddExtensionData(data);
            }

            // Add the sections to the librarian
            List <Section> sections = new List <Section>();

            foreach (string file in this.commandLine.Files)
            {
                string     inputFile = Path.GetFullPath(file);
                FileFormat format    = FileStructure.GuessFileFormatFromExtension(Path.GetExtension(inputFile));
                bool       retry;
                do
                {
                    retry = false;

                    try
                    {
                        switch (format)
                        {
                        case FileFormat.Wixobj:
                            Intermediate intermediate = Intermediate.Load(inputFile, librarian.TableDefinitions, this.commandLine.SuppressVersionCheck);
                            sections.AddRange(intermediate.Sections);
                            break;

                        default:
                            Library loadedLibrary = Library.Load(inputFile, librarian.TableDefinitions, this.commandLine.SuppressVersionCheck);
                            sections.AddRange(loadedLibrary.Sections);
                            break;
                        }
                    }
                    catch (WixUnexpectedFileFormatException e)
                    {
                        format = e.FileFormat;
                        retry  = (FileFormat.Wixobj == format || FileFormat.Wixlib == format); // .wixobj and .wixout are supported by lit.
                        if (!retry)
                        {
                            Messaging.Instance.OnMessage(e.Error);
                        }
                    }
                } while (retry);
            }

            // Stop processing if any errors were found loading object files.
            if (Messaging.Instance.EncounteredError)
            {
                return;
            }

            // and now for the fun part
            Library library = librarian.Combine(sections);

            // Add any localization files and save the library output if an error did not occur
            if (null != library)
            {
                foreach (string localizationFile in this.commandLine.LocalizationFiles)
                {
                    Localization localization = Localizer.ParseLocalizationFile(localizationFile, librarian.TableDefinitions);
                    if (null != localization)
                    {
                        library.AddLocalization(localization);
                    }
                }

                // If there was an error adding localization files, then bail.
                if (Messaging.Instance.EncounteredError)
                {
                    return;
                }

                LibraryBinaryFileResolver resolver = null;
                if (this.commandLine.BindFiles)
                {
                    resolver = new LibraryBinaryFileResolver();
                    resolver.FileManagers     = this.fileManagers;
                    resolver.VariableResolver = new WixVariableResolver();

                    BinderFileManagerCore core = new BinderFileManagerCore();
                    core.AddBindPaths(this.commandLine.BindPaths, BindStage.Normal);

                    foreach (IBinderFileManager fileManager in resolver.FileManagers)
                    {
                        fileManager.Core = core;
                    }
                }

                library.Save(this.commandLine.OutputFile, resolver);
            }
        }