/// <summary>
        /// Generates the final output from a set of intermediates.
        /// </summary>
        /// <param name="intermediates">Intermediates that provide data to be generated.</param>
        /// <param name="outputPath">Path for output file to be generated.</param>
        public override void Generate(IEnumerable <Intermediate> intermediates, string outputPath)
        {
            if (this.OutputType != CompilerOutputType.WixLibrary)
            {
                throw new NotImplementedException("Only creating .wixlib files is currently supported.");
            }

            this.WixItems = this.ProcessIntermediates(intermediates);

            XElement library = new XElement(WixBackendCompilerServices.WixlibNamespace + "wixLibrary",
                                            new XAttribute("version", WixBackendCompilerServices.WixlibVersion));

            foreach (WixItem item in this.WixItems.Values)
            {
                if (item.System) // skip system items.
                {
                    continue;
                }

                WixSection section = item.GenerateSection();
                if (section != null)
                {
                    library.Add(section.Xml);
                }
            }

            FileTransfer wixlibTransfer = FileTransfer.Create(null, IO.Path.GetTempFileName(), outputPath, "WixLibrary", true);

            using (IO.Stream wixlibStream = IO.File.Open(wixlibTransfer.Source, IO.FileMode.Create, IO.FileAccess.ReadWrite, IO.FileShare.Delete))
            {
                library.Save(wixlibStream);
            }

            FileTransfer.ExecuteTransfer(this, wixlibTransfer);
        }
        /// <summary>
        /// Generates the final output from a set of intermediates.
        /// </summary>
        /// <param name="intermediates">Intermediates that provide data to be generated.</param>
        /// <param name="outputPath">Path for output file to be generated.</param>
        public override void Generate(IEnumerable <Intermediate> intermediates, string outputPath)
        {
            NugetManifest manifest = new NugetManifest(this);

            manifest.ProcessIntermediates(intermediates);
            if (this.EncounteredError)
            {
                return;
            }

            manifest.Validate(this.ValidationErrorHandler);
            if (this.EncounteredError)
            {
                string tempPath = Path.GetTempFileName();
                this.OnMessage(new CompilerMessageEventArgs(CompilerMessage.SavedManifest(tempPath), null, 0, 0));

                this.SaveManifest(manifest, tempPath);
                return;
            }

            FileTransfer packageTransfer = FileTransfer.Create(null, Path.GetTempFileName(), outputPath, "NugetPackage", true);

            using (Package package = Package.Open(packageTransfer.Source, FileMode.Create))
            {
                // Add all the manifest files.
                foreach (PackageFile file in manifest.Files)
                {
                    this.OnMessage(new CompilerMessageEventArgs(CompilerMessage.CompressFile(file.SourcePath), file.File.LineNumber));

                    using (Stream fileStream = File.Open(file.SourcePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        PackagePart part = package.CreatePart(new Uri(file.PartUri, UriKind.Relative), file.MimeType, CompressionOption.Maximum);
                        this.SaveStreamToPart(fileStream, part);
                    }
                }

                var manifestUri = new Uri(String.Concat("/", manifest.Name, ".nuspec"), UriKind.Relative);

                // Create the manifest relationship
                package.CreateRelationship(manifestUri, TargetMode.Internal, "http://schemas.microsoft.com/packaging/2010/07/manifest");

                // Save the manifest to the package.
                using (Stream manifestStream = manifest.GetStream())
                {
                    PackagePart part = package.CreatePart(manifestUri, "application/octet", CompressionOption.Maximum);
                    this.SaveStreamToPart(manifestStream, part);
                }

                package.PackageProperties.Creator        = manifest.Manufacturer;
                package.PackageProperties.Description    = manifest.Description;
                package.PackageProperties.Identifier     = manifest.Name;
                package.PackageProperties.Version        = manifest.Version;
                package.PackageProperties.Language       = manifest.Language;
                package.PackageProperties.Keywords       = manifest.Tags;
                package.PackageProperties.Title          = manifest.DisplayName;
                package.PackageProperties.LastModifiedBy = "WiX Toolset v#.#.#.#";
            }

            FileTransfer.ExecuteTransfer(this, packageTransfer);
        }
        /// <summary>
        /// Generates the final output from a set of intermediates.
        /// </summary>
        /// <param name="intermediates">Intermediates that provide data to be generated.</param>
        /// <param name="outputPath">Path for output file to be generated.</param>
        public override void Generate(IEnumerable <Intermediate> intermediates, string outputPath)
        {
            VsixManifest manifest = new VsixManifest(this);

            manifest.ProcessIntermediates(intermediates);
            if (this.EncounteredError)
            {
                return;
            }

            manifest.Validate(this.ValidationErrorHandler);
            if (this.EncounteredError)
            {
                string tempPath = Path.GetTempFileName();
                this.OnMessage(new CompilerMessageEventArgs(CompilerMessage.SavedManifest(tempPath), null, 0, 0));

                this.SaveManifest(manifest, tempPath);
                return;
            }

            FileTransfer packageTransfer = FileTransfer.Create(null, Path.GetTempFileName(), outputPath, "VsixPackage", true);

            using (Package package = Package.Open(packageTransfer.Source, FileMode.Create))
            {
                // Add all the manifest files.
                foreach (PackageFile file in manifest.Files)
                {
                    this.OnMessage(new CompilerMessageEventArgs(CompilerMessage.CompressFile(file.SourcePath), file.File.LineNumber));

                    using (Stream fileStream = File.Open(file.SourcePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        PackagePart part = package.CreatePart(new Uri(file.PartUri, UriKind.Relative), file.MimeType, CompressionOption.Normal);
                        this.SaveStreamToPart(fileStream, part);
                    }
                }

                // Save the manifest to the package.
                using (Stream manifestStream = manifest.GetStream())
                {
                    PackagePart part = package.CreatePart(new Uri("/extension.vsixmanifest", UriKind.Relative), "text/xml", CompressionOption.Normal);
                    this.SaveStreamToPart(manifestStream, part);
                }
            }

            FileTransfer.ExecuteTransfer(this, packageTransfer);
        }
        /// <summary>
        /// Generates the final output from a set of intermediates.
        /// </summary>
        /// <param name="intermediates">Intermediates that provide data to be generated.</param>
        /// <param name="outputPath">Path for output file to be generated.</param>
        public override void Generate(IEnumerable <Intermediate> intermediates, string outputPath)
        {
            AppxManifest manifest = new AppxManifest(this);

            manifest.ProcessIntermediates(intermediates);
            if (this.EncounteredError)
            {
                return;
            }

            manifest.Validate(this.ValidationErrorHandler);
            if (this.EncounteredError)
            {
                string tempPath = Path.GetTempFileName();
                this.OnMessage(new CompilerMessageEventArgs(CompilerMessage.SavedManifest(tempPath), null, 0, 0));

                this.SaveManifest(manifest, tempPath);
                return;
            }

            FileTransfer appxPackageTransfer = FileTransfer.Create(null, Path.GetTempFileName(), outputPath, "AppxPackage", true);

            using (Stream packageStream = File.Open(appxPackageTransfer.Source, FileMode.Create, FileAccess.ReadWrite, FileShare.Delete))
            {
                AppxPackage package = new AppxPackage(packageStream);

                foreach (PackageFile file in manifest.Files)
                {
                    using (Stream fileStream = File.Open(file.SourcePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        this.OnMessage(new CompilerMessageEventArgs(CompilerMessage.CompressFile(file.SourcePath), file.File.LineNumber));
                        package.AddFile(fileStream, file.PartUri, file.MimeType, CompressionLevel.DefaultCompression);
                    }
                }

                using (Stream manifestStream = manifest.GetStream())
                {
                    package.Finish(manifestStream);
                }
            }

            FileTransfer.ExecuteTransfer(this, appxPackageTransfer);
        }