Esempio n. 1
0
        /// <summary>
        /// Builds the setup package and feed.
        /// </summary>
        /// <param name="outputFeed">Path to the file where feed will be generated.</param>
        /// <returns>True if fabrication was successful, false if any failure occurs.</returns>
        public override bool Fabricate(string outputFeed)
        {
            this.VerifyRequiredInformation();

            try
            {
                this.Core = new FabricatorCore(this.MessageHandler);

                // Calculate the paths required to build the MSI.
                string localSetupFeed = outputFeed;
                Uri urlSetupFeed = new Uri(this.UpdateUrl, Path.GetFileName(localSetupFeed));
                string outputMsi = Path.GetTempFileName();

                string previousPackagePath = null;

                // Create the feed builder and open the previous feed if it was provided.
                FeedBuilder feedBuilder = new FeedBuilder(this.Core);

                if (this.previousFeedUrl != null)
                {
                    feedBuilder.OpenPrevious(this.previousFeedUrl);
                    previousPackagePath = feedBuilder.GetPreviousAppItemPath();

                    if (String.Compare(Path.GetExtension(previousPackagePath), ".exe", true) == 0)
                    {
                        previousPackagePath = SetupExeBuilder.GetEmbeddedPackage(previousPackagePath);
                    }
                }

                // Create the MSI builder and open the previous package if there was one.
                IsolatedMsiBuilder msiBuilder = new IsolatedMsiBuilder(this.Core);

                if (previousPackagePath != null)
                {
                    msiBuilder.OpenPrevious(previousPackagePath);
                }

                // Build the MSI.
                msiBuilder.Description = this.Description;
                msiBuilder.EntryFileRelativePath = this.EntryPoint;
                msiBuilder.Manufacturer = this.Manufacturer;
                msiBuilder.Name = this.Name;
                msiBuilder.Source = this.Source;
                msiBuilder.UpdateUrl = urlSetupFeed;
                msiBuilder.UpgradeCode = this.ApplicationId;
                msiBuilder.Version = this.ApplicationVersion;
                if (!msiBuilder.Build(outputMsi, this.saveWxsPath))
                {
                    return false;
                }

                // Calculate the paths required to build the setup.exe.
                string relativeSetupExe = Path.Combine(msiBuilder.Version.ToString(), "setup.exe");
                string localSetupExe = Path.Combine(Path.GetDirectoryName(outputFeed), relativeSetupExe);

                // Build the setup.exe.
                SetupExeBuilder setupExeBuilder = new SetupExeBuilder(this.Core);
                setupExeBuilder.MsiPath = outputMsi;
                if (!setupExeBuilder.Build(localSetupExe))
                {
                    return false;
                }

                // Calculate the paths required for the app feed.
                Uri urlSetupExe = new Uri(this.updateUrl, relativeSetupExe);

                // Build the application feed.  Note some values come from the MSI build because
                // they were updated there.
                feedBuilder.ApplicationId = msiBuilder.ProductCode;
                feedBuilder.ApplicationName = this.Name;
                feedBuilder.ApplicationVersion = msiBuilder.Version;
                feedBuilder.Description = this.Description;
                feedBuilder.Generator = "WiX Toolset's ClickThrough for Isolated Applications";
                feedBuilder.Id = msiBuilder.UpgradeCode;
                feedBuilder.PackagePath = localSetupExe;
                feedBuilder.PackageUrl = urlSetupExe;
                feedBuilder.TimeToLive = this.updateRate;
                feedBuilder.Title = String.Concat(this.Manufacturer, "'s ", this.Name);
                feedBuilder.Url = this.UpdateUrl;
                return feedBuilder.Build(localSetupFeed);
            }
            finally
            {
                this.Core = null;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Builds the setup package and feed.
        /// </summary>
        /// <param name="outputFeed">Path to the file where feed will be generated.</param>
        /// <returns>True if fabrication succeeded, false if anything went wrong.</returns>
        public override bool Fabricate(string outputFeed)
        {
            this.VerifyRequiredInformation();

            try
            {
                this.Core = new FabricatorCore(this.MessageHandler);

                // Calculate the paths required to build the MSI.
                string localSetupFeed = outputFeed;
                Uri    urlSetupFeed   = new Uri(this.updateUrl, Path.GetFileName(localSetupFeed));
                string shimPath       = Path.GetTempFileName();
                string outputMsi      = Path.GetTempFileName();
                Guid   addinId        = this.ApplicationId == Guid.Empty ? Guid.NewGuid() : this.ApplicationId;

                string previousPackagePath = null;

                // Create the feed builder and open the previous feed if it was provided.
                FeedBuilder feedBuilder = new FeedBuilder(this.Core);

                if (this.previousFeedUrl != null)
                {
                    feedBuilder.OpenPrevious(this.previousFeedUrl);
                    previousPackagePath = feedBuilder.GetPreviousAppItemPath();

                    if (String.Compare(Path.GetExtension(previousPackagePath), ".exe", true) == 0)
                    {
                        previousPackagePath = SetupExeBuilder.GetEmbeddedPackage(previousPackagePath);
                    }
                }

                // Create the shim builder.
                OfficeShimBuilder shimBuilder = new OfficeShimBuilder(this.Core);
                shimBuilder.AddinPath = Path.Combine(this.Source, this.EntryPoint);
                shimBuilder.AddinId   = addinId.ToString("B");
                shimBuilder.Build(shimPath);

                // Create the MSI builder and open the previous package if there was one.
                OfficeAddinMsiBuilder msiBuilder = new OfficeAddinMsiBuilder(this.Core);

                if (previousPackagePath != null)
                {
                    msiBuilder.OpenPrevious(previousPackagePath);
                }

                // Build the MSI.
                msiBuilder.Description = this.description;
                msiBuilder.ExtendedOfficeApplications.AddRange(this.extendedOfficeApplications);
                msiBuilder.EntryFileRelativePath = this.entryPoint;
                msiBuilder.Manufacturer          = this.Manufacturer;
                msiBuilder.Name        = this.Name;
                msiBuilder.ProductCode = addinId;
                msiBuilder.ShimPath    = shimPath;
                msiBuilder.ShimClsid   = shimBuilder.AddinClsid;
                msiBuilder.ShimProgid  = shimBuilder.AddinProgId;
                msiBuilder.Source      = this.Source;
                msiBuilder.UpdateUrl   = urlSetupFeed;
                msiBuilder.UpgradeCode = this.ApplicationId;
                msiBuilder.Version     = this.ApplicationVersion;
                if (!msiBuilder.Build(outputMsi, this.saveWxsPath))
                {
                    return(false);
                }

                // Calculate the paths required to build the setup.exe.
                string relativeSetupExe = Path.Combine(msiBuilder.Version.ToString(), "setup.exe");
                string localSetupExe    = Path.Combine(Path.GetDirectoryName(outputFeed), relativeSetupExe);

                // Build the setup.exe.
                SetupExeBuilder setupExeBuilder = new SetupExeBuilder(this.Core);
                setupExeBuilder.MsiPath = outputMsi;
                if (!setupExeBuilder.Build(localSetupExe))
                {
                    return(false);
                }

                // Calculate the paths required for the app feed.
                Uri urlSetupExe = new Uri(this.updateUrl, relativeSetupExe);

                // Build the application feed.  Note some values come from the MSI build because
                // they were updated there.
                feedBuilder.ApplicationId      = msiBuilder.ProductCode;
                feedBuilder.ApplicationName    = this.Name;
                feedBuilder.ApplicationVersion = msiBuilder.Version;
                feedBuilder.Description        = this.Description;
                feedBuilder.Generator          = "WiX Toolset's ClickThrough for Office Addins";
                feedBuilder.Id          = msiBuilder.UpgradeCode;
                feedBuilder.PackagePath = localSetupExe;
                feedBuilder.PackageUrl  = urlSetupExe;
                feedBuilder.TimeToLive  = this.UpdateRate;
                feedBuilder.Title       = String.Concat(this.Manufacturer, "'s ", this.Name);
                feedBuilder.Url         = this.UpdateUrl;
                return(feedBuilder.Build(localSetupFeed));
            }
            finally
            {
                this.Core = null;
            }
        }