Exemple #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            var bootstrapperBuilder = new BootstrapperBuilder();
            var bootstrapper        = bootstrapperBuilder.Build();

            bootstrapper.OpenNewWindow(
                new StartVM(),
                vm => vm.WindowTitle = string.Empty,
                null,
                null,
                nav => nav.ViewNavigator.ShowDialog("Вы точно хотите выйти из программы?", ModalIcon.Question, "Выход", "Выйти", "Отмена"));
        }
        public override bool Execute()
        {
            BootstrapperBuilder builder = new BootstrapperBuilder {
                Validate = this.Validate,
                Path     = this.Path
            };
            ProductCollection products = builder.Products;
            BuildSettings     settings = new BuildSettings {
                ApplicationFile = this.ApplicationFile,
                ApplicationName = this.ApplicationName,
                ApplicationRequiresElevation = this.ApplicationRequiresElevation,
                ApplicationUrl     = this.ApplicationUrl,
                ComponentsLocation = this.ConvertStringToComponentsLocation(this.ComponentsLocation),
                ComponentsUrl      = this.ComponentsUrl,
                CopyComponents     = this.CopyComponents,
                Culture            = this.culture,
                FallbackCulture    = this.fallbackCulture,
                OutputPath         = this.OutputPath,
                SupportUrl         = this.SupportUrl
            };

            if (this.BootstrapperItems != null)
            {
                Hashtable hashtable = new Hashtable(StringComparer.OrdinalIgnoreCase);
                foreach (ITaskItem item in this.BootstrapperItems)
                {
                    string metadata = item.GetMetadata("Install");
                    if (string.IsNullOrEmpty(metadata) || ConversionUtilities.ConvertStringToBool(metadata))
                    {
                        if (!hashtable.Contains(item.ItemSpec))
                        {
                            hashtable.Add(item.ItemSpec, item);
                        }
                        else
                        {
                            base.Log.LogWarningWithCodeFromResources("GenerateBootstrapper.DuplicateItems", new object[] { item.ItemSpec });
                        }
                    }
                }
                foreach (Product product in products)
                {
                    if (hashtable.Contains(product.ProductCode))
                    {
                        settings.ProductBuilders.Add(product.ProductBuilder);
                        hashtable.Remove(product.ProductCode);
                    }
                }
                foreach (ITaskItem item2 in hashtable.Values)
                {
                    base.Log.LogWarningWithCodeFromResources("GenerateBootstrapper.ProductNotFound", new object[] { item2.ItemSpec, builder.Path });
                }
            }
            BuildResults results = builder.Build(settings);

            BuildMessage[] messages = results.Messages;
            if (messages != null)
            {
                foreach (BuildMessage message in messages)
                {
                    if (message.Severity == BuildMessageSeverity.Error)
                    {
                        base.Log.LogError(null, message.HelpCode, message.HelpKeyword, null, 0, 0, 0, 0, message.Message, new object[0]);
                    }
                    else if (message.Severity == BuildMessageSeverity.Warning)
                    {
                        base.Log.LogWarning(null, message.HelpCode, message.HelpKeyword, null, 0, 0, 0, 0, message.Message, new object[0]);
                    }
                }
            }
            this.BootstrapperKeyFile        = results.KeyFile;
            this.BootstrapperComponentFiles = results.ComponentFiles;
            return(results.Succeeded);
        }
        /// <summary>
        /// Generate the bootstrapper.
        /// </summary>
        /// <returns> Return true on success, false on failure.</returns>
        public override bool Execute()
        {
            if (_path == null)
            {
                _path = Util.GetDefaultPath(_visualStudioVersion);
            }

            BootstrapperBuilder bootstrapperBuilder = new BootstrapperBuilder();

            bootstrapperBuilder.Validate = this.Validate;
            bootstrapperBuilder.Path     = this.Path;

            ProductCollection products = bootstrapperBuilder.Products;

            BuildSettings settings = new BuildSettings();

            settings.ApplicationFile = ApplicationFile;
            settings.ApplicationName = ApplicationName;
            settings.ApplicationRequiresElevation = ApplicationRequiresElevation;
            settings.ApplicationUrl     = ApplicationUrl;
            settings.ComponentsLocation = ConvertStringToComponentsLocation(this.ComponentsLocation);
            settings.ComponentsUrl      = ComponentsUrl;
            settings.CopyComponents     = CopyComponents;
            settings.Culture            = _culture;
            settings.FallbackCulture    = _fallbackCulture;
            settings.OutputPath         = this.OutputPath;
            settings.SupportUrl         = this.SupportUrl;

            if (String.IsNullOrEmpty(settings.Culture) || settings.Culture == "*")
            {
                settings.Culture = settings.FallbackCulture;
            }

            if (this.BootstrapperItems != null)
            {
                // The bootstrapper items may not be in the correct order, because XMake saves
                // items in alphabetical order.  So we will attempt to put items into the correct
                // order, according to the Products order in the search.  To do this, we add all
                // the items we are told to build into a hashtable, then go through our products
                // in order, looking to see if the item is built.  If it is, remove the item from
                // the hashtable.  All remaining items in the table can not be built, so errors
                // will be issued.
                Hashtable items = new Hashtable(StringComparer.OrdinalIgnoreCase);

                foreach (ITaskItem bootstrapperItem in this.BootstrapperItems)
                {
                    string installAttribute = bootstrapperItem.GetMetadata("Install");
                    if (String.IsNullOrEmpty(installAttribute) || Shared.ConversionUtilities.ConvertStringToBool(installAttribute))
                    {
                        if (!items.Contains(bootstrapperItem.ItemSpec))
                        {
                            items.Add(bootstrapperItem.ItemSpec, bootstrapperItem);
                        }
                        else
                        {
                            Log.LogWarningWithCodeFromResources("GenerateBootstrapper.DuplicateItems", bootstrapperItem.ItemSpec);
                        }
                    }
                }

                foreach (Product product in products)
                {
                    if (items.Contains(product.ProductCode))
                    {
                        settings.ProductBuilders.Add(product.ProductBuilder);
                        items.Remove(product.ProductCode);
                    }
                }

                foreach (ITaskItem bootstrapperItem in items.Values)
                {
                    Log.LogWarningWithCodeFromResources("GenerateBootstrapper.ProductNotFound", bootstrapperItem.ItemSpec, bootstrapperBuilder.Path);
                }
            }

            BuildResults results = bootstrapperBuilder.Build(settings);

            BuildMessage[] messages = results.Messages;

            if (messages != null)
            {
                foreach (BuildMessage message in messages)
                {
                    if (message.Severity == BuildMessageSeverity.Error)
                    {
                        Log.LogError(null, message.HelpCode, message.HelpKeyword, null, 0, 0, 0, 0, message.Message);
                    }
                    else if (message.Severity == BuildMessageSeverity.Warning)
                    {
                        Log.LogWarning(null, message.HelpCode, message.HelpKeyword, null, 0, 0, 0, 0, message.Message);
                    }
                }
            }

            this.BootstrapperKeyFile        = results.KeyFile;
            this.BootstrapperComponentFiles = results.ComponentFiles;

            return(results.Succeeded);
        }
Exemple #4
0
        private static void Main()
        {
            var bootstrapperBuilder = new BootstrapperBuilder();

            bootstrapperBuilder.Build();
        }