Ejemplo n.º 1
0
        /// <summary>
        /// Creates the setup wizard and runs the application thread.
        /// </summary>
        private void Run()
        {
            this._app = new Application();
            RxApp.MainThreadScheduler    = new DispatcherScheduler(_app.Dispatcher);
            Application.ResourceAssembly = typeof(MainWindow).Assembly;

            string version;

            this._session.TryGetValue("CurrentVersion", out version);

            var model = InstallationModel.Create(new WixStateProvider(version), new SessionWrapper(_session));

            this._mainWindow = new MainWindow(model, this._installStartEvent);
            this._app.Run(this._mainWindow);
            this._installExitEvent.Set();
        }
Ejemplo n.º 2
0
        public void Application_Startup(object sender, StartupEventArgs e)
        {
            var wix   = new DemoWixStateProvider();
            var model = InstallationModel.Create(wix, new NoopSession());

            var window = new MainWindow(model, new ManualResetEvent(false));

            model.InstallUITask = async() =>
            {
                await Task.Delay(TimeSpan.FromSeconds(1));

                return(Observable.Return(ClosingResult.Failed));
            };
            model.AllSteps.Last().IsSelected = true;
            window.Show();

            RxApp.MainThreadScheduler = new DispatcherScheduler(Application.Current.Dispatcher);

            Application.Current.Resources["InstallerTitle"] = wix.CurrentVersion.ToString();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var productName      = args[0].ToLower();
            var product          = GetProduct(productName);
            var version          = args[1];
            var distributionRoot = Path.Combine(args[2], $"{productName}-{version}");;


            // set properties in the MSI so that they don't have to be set on the command line.
            // The only awkward one is plugins as it has a not empty default value, but an empty
            // string can be passed to not install any plugins
            var model            = InstallationModel.Create(new NoopWixStateProvider(), new NoopSession());
            var setupParams      = model.ToMsiParams();
            var staticProperties = setupParams
                                   .Where(v => v.Attribute.IsStatic)
                                   .Select(a => new Property(a.Key, a.Value)
                                           );

            // Only set dynamic property if MSI is not installed and value is empty
            var dynamicProperties = setupParams
                                    .Where(v => v.Attribute.IsDynamic)
                                    .Select(a => new SetPropertyAction(
                                                a.Key,
                                                a.Attribute.DynamicValue,
                                                Return.check,
                                                When.After,
                                                Step.PreviousActionOrInstallInitialize,
                                                new Condition($"(NOT Installed) AND ({a.Key}=\"\")")
                                                )
                                            );

            var project = new Project
            {
                ProductId        = product.ProductCode[version],
                UpgradeCode      = product.UpgradeCode,
                GUID             = product.UpgradeCode,
                ControlPanelInfo = new ProductInfo
                {
                    Manufacturer = "Elastic",
                    ProductIcon  = $@"Resources\{productName}.ico",
                    // Shows up as Support Link in Programs and Features
                    UrlInfoAbout = $"https://www.elastic.co/products/{productName}",
                    // Shows up as Help Link in Programs and Features
                    HelpLink = $"https://discuss.elastic.co/c/{productName}"
                },
                Name        = CultureInfo.CurrentCulture.TextInfo.ToTitleCase($"{productName} ") + version,
                OutFileName = productName,
                Version     = new Version(version.Split('-')[0]),
                Actions     = dynamicProperties
                              .Concat(System.Reflection.Assembly.GetExecutingAssembly().GetTypes()
                                      .Where(t => t != typeof(CustomAction) && typeof(CustomAction).IsAssignableFrom(t) && !t.IsAbstract)
                                      .Select(t => (CustomAction)Activator.CreateInstance(t))
                                      .Where(c => c.ProductType == product.GetType())
                                      .OrderBy(c => c.Order)
                                      .Select(c => c.ToManagedAction())
                                      .ToArray <WixSharp.Action>()).ToArray(),
                DefaultFeature = new Feature("Complete", true, false),
                Platform       = Platform.x64,
                InstallScope   = InstallScope.perMachine,
                Properties     = new[]
                {
                    // make it easy to reference current version within MSI process
                    new Property("CurrentVersion", version),
                    new Property("MsiLogging", "voicewarmup"),
                    // do not give option to repair installation
                    new Property("ARPNOREPAIR", "yes"),
                    // do not give option to change installation
                    new Property("ARPNOMODIFY", "yes"),
                    new PropertyRef("NETFRAMEWORK45"),
                }.Concat(staticProperties).ToArray(),
                LaunchConditions = new List <LaunchCondition>
                {
                    new LaunchCondition(
                        "Installed OR NETFRAMEWORK45",
                        "This installer requires at least .NET Framework 4.5 in order to run custom install actions. " +
                        "Please install .NET Framework 4.5 then run this installer again."
                        )
                },
                Dirs = new[]
                {
                    new Dir(@"ProgramFiles64Folder")
                    {
                        Dirs = new []
                        {
                            new Dir(new Id("Elastic"), "Elastic")
                            {
                                Dirs = new []
                                {
                                    new Dir(new Id("INSTALLDIR"), CultureInfo.CurrentCulture.TextInfo.ToTitleCase(productName))
                                    {
                                        DirFileCollections = new []
                                        {
                                            new DirFiles(distributionRoot + @"\*.*")
                                        },
                                        Dirs = product.Files(distributionRoot).ToArray()
                                    }
                                }
                            }
                        }
                    }
                }
            };

            if (product.EmbeddedUI != null)
            {
                project.EmbeddedUI = new EmbeddedAssembly(product.EmbeddedUI.Assembly.Location);
            }
            else
            {
                project.UI = WUI.WixUI_ProgressOnly;
            }

            project.MajorUpgradeStrategy = MajorUpgradeStrategy.Default;
            project.MajorUpgradeStrategy.RemoveExistingProductAfter = Step.InstallValidate;
            project.WixSourceGenerated += PatchWixSource;
            project.IncludeWixExtension(WixExtension.NetFx);

            Compiler.BuildWxs(project, $@"_Generated\{productName.ToLower()}.wxs", Compiler.OutputType.MSI);
            Compiler.BuildMsi(project);
        }
 protected InstallationTask(string[] args, ISession session)
     : this(InstallationModel.Create(new NoopWixStateProvider(), session, args), session, new FileSystem())
 {
     this.Args = args;
 }