Exemplo n.º 1
0
        public void ArrayExtensions()
        {
            var project = new Project();

            project.Actions = new Action[] { new ManagedAction() };
            //should not throw
            project.AddAction(new InstalledFileAction("", ""));
            project.AddActions(project.Actions);
        }
Exemplo n.º 2
0
        public void Fix_Issue_60()
        {
            var project = new Project("MyProduct",
                              new Dir("%ProgramFiles%",
                              new File("abc.txt", new FilePermission("Guest", GenericPermission.All))));

            project.AddAction(new QtCmdLineAction("cmd.exe", "/c \"echo abc\""));

            var batchFile = project.BuildMsiCmd();
            string cmd = System.IO.File.ReadAllLines(batchFile).First();

            int firstPos = cmd.IndexOf("WixUtilExtension.dll");
            int lastPos = cmd.LastIndexOf("WixUtilExtension.dll");

            Assert.Equal(firstPos, lastPos);
        }
Exemplo n.º 3
0
        public void Fix_Issue_60()
        {
            var project = new Project("MyProduct",
                                      new Dir("%ProgramFiles%",
                                              new File("abc.txt", new FilePermission("Guest", GenericPermission.All))));

            project.AddAction(new WixQuietExecAction("cmd.exe", "/c \"echo abc\""));

            var    batchFile = project.BuildMsiCmd();
            string cmd       = System.IO.File.ReadAllLines(batchFile).First();

            int firstPos = cmd.IndexOf("WixUtilExtension.dll");
            int lastPos  = cmd.LastIndexOf("WixUtilExtension.dll");

            Assert.Equal(firstPos, lastPos);
        }
    static void InjectProductActivationDialog(Project project)
    {
        //Injects CLR dialog CustomDialog between MSI dialogs LicenseAgreementDlg and InstallDirDlg.
        //Passes custom action ShowProductActivationDialog for instantiating and popping up the CLR dialog.

        //This is practically a full equivalent of the WixSharp.CommonTasks.Tasks.InjectClrDialog(this Project project,...) extension method,
        //except it places and additional LicenseAccepted condition

        ManagedAction customDialog = new ShowClrDialogAction("ShowProductActivationDialog");

        project.AddAction(customDialog);

        project.UI = WUI.WixUI_Common;

        var customUI = new CommomDialogsUI();

        var prevDialog = NativeDialogs.LicenseAgreementDlg;
        var nextDialog = NativeDialogs.InstallDirDlg;

        //disconnect prev and next dialogs
        customUI.UISequence.RemoveAll(x => (x.Dialog == prevDialog && x.Control == Buttons.Next) ||
                                      (x.Dialog == nextDialog && x.Control == Buttons.Back));

        //create new dialogs connection with showAction in between
        customUI.On(prevDialog, Buttons.Next, new ExecuteCustomAction(customDialog.Id));
        customUI.On(prevDialog, Buttons.Next, new ShowDialog(nextDialog, Condition.ClrDialog_NextPressed + " AND LicenseAccepted = \"1\""));
        customUI.On(prevDialog, Buttons.Next, new CloseDialog("Exit", Condition.ClrDialog_CancelPressed)
        {
            Order = 2
        });

        customUI.On(nextDialog, Buttons.Back, new ExecuteCustomAction(customDialog.Id));
        customUI.On(nextDialog, Buttons.Back, new ShowDialog(prevDialog, Condition.ClrDialog_BackPressed));

        project.CustomUI = customUI;
    }
Exemplo n.º 5
0
        private static string BuildMSI(Platform platform, string dataFolder, string versionStr)
        {
            string platformString;
            string platformString2;

            if (platform == Platform.x86)
            {
                platformString  = "x86";
                platformString2 = "Intel;";
            }
            else if (platform == Platform.x64)
            {
                platformString  = "x64";
                platformString2 = "x64;";
            }
            else
            {
                throw new NotSupportedException("Unsupported Platform");
            }

            string outputFilename = $"PersonalHouse-{versionStr}-{platformString}";

            var project =

                new Project("!(loc.PersonalCloudFolderName)",

                            new Dir($@"%ProgramFiles%\Personal House {versionStr}",

                                    new Dir("Service",

                                            new WixSharp.Files(Path.Combine(dataFolder, $@"Service\{platformString}\*.*"),
                                                               f => !f.EndsWith(".obj") &&
                                                               !f.EndsWith(".pdb"))
            {
                AttributesDefinition = "ReadOnly=no"
            },

                                            new WixSharp.Files(Path.Combine(dataFolder, $@"dokan_bin\{platformString}\*.*"),
                                                               f => !f.EndsWith(".obj") &&
                                                               !f.EndsWith(".pdb"))
            {
                AttributesDefinition = "ReadOnly=no"
            },

                                            new WixSharp.Files(Path.Combine(dataFolder, $@"ffmpeg_bin\{platformString}\*.*"),
                                                               f => !f.EndsWith(".obj") &&
                                                               !f.EndsWith(".pdb"))
            {
                AttributesDefinition = "ReadOnly=no"
            }
                                            ),

                                    new Dir("GUI",

                                            new WixSharp.Files(Path.Combine(dataFolder, @"GUI\*.*"),
                                                               f => !f.EndsWith(".obj") &&
                                                               !f.EndsWith(".pdb"))
            {
                AttributesDefinition = "ReadOnly=no"
            }
                                            )
                                    )
                            );

            project.AddProperty(new Property("WIXUI_EXITDIALOGOPTIONALCHECKBOX", "1"));
            project.AddProperty(new Property("WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT", "!(loc.LaunchConfigurator)"));
            project.AddAction(new ManagedAction(CustomActions.LaunchApplication)
            {
                Execute = Execute.immediate
            });

            project.GUID        = new Guid("B8B67678-128E-47D8-BE23-90132BCF220F");
            project.UpgradeCode = new Guid("B8B67678-128E-47D8-BE23-90132BCF1058");

            project.MajorUpgrade = new MajorUpgrade
            {
                Schedule = UpgradeSchedule.afterInstallInitialize,
                DowngradeErrorMessage = "A later version of [ProductName] is already installed. Setup will now exit."
            };

            project.Platform = platform;

            project.ResolveWildCards(ignoreEmptyDirectories: true);

            var personalCloudConfigExeFile = project.AllFiles.Single(f => f.Name.EndsWith("PersonalCloud.WindowsConfigurator.exe"));

            personalCloudConfigExeFile
            .AddShortcut(new FileShortcut("!(loc.PersonalCloudConfiguratorShortcutTitle)", @"%ProgramMenu%\!(loc.PersonalCloudFolderName)"))
            .AddShortcut(new FileShortcut("!(loc.PersonalCloudConfiguratorShortcutTitle)", @"%Desktop%"))
            .AddShortcut(new FileShortcut("!(loc.PersonalCloudConfiguratorShortcutTitle)", @"%Startup%")
            {
                Arguments = "/Startup"
            });

            var personalCloudServiceExeFile = project.AllFiles.Single(f => f.Name.EndsWith("PersonalCloud.WindowsService.exe"));

            personalCloudServiceExeFile.Add(new FirewallException {
                Name = "Personal House Service", Scope = FirewallExceptionScope.any
            });

            personalCloudServiceExeFile.ServiceInstaller = new ServiceInstaller
            {
                Name                         = "PersonalCloud.WindowsService",
                DisplayName                  = "Personal House Service",
                StartOn                      = SvcEvent.Install,
                StopOn                       = SvcEvent.InstallUninstall_Wait,
                RemoveOn                     = SvcEvent.Uninstall_Wait,
                DelayedAutoStart             = true,
                ServiceSid                   = ServiceSid.none,
                FirstFailureActionType       = FailureActionType.restart,
                SecondFailureActionType      = FailureActionType.restart,
                ThirdFailureActionType       = FailureActionType.restart,
                RestartServiceDelayInSeconds = 30,
                ResetPeriodInDays            = 1,
            };

            project.UI                = WUI.WixUI_InstallDir;
            project.Version           = new Version(versionStr);
            project.InstallScope      = InstallScope.perMachine;
            project.PreserveTempFiles = true;
            project.OutFileName       = outputFilename;
            project.BackgroundImage   = Path.Combine(dataFolder, "dlgbmp.png");
            project.BannerImage       = Path.Combine(dataFolder, "bannerbmp.bmp");

            project.Include(WixExtension.Util);
            project.WixSourceGenerated += Project_WixSourceGenerated;

            project.Language         = "en-US";
            project.LocalizationFile = @"Localization\en-US.wxl";
            project.LicenceFile      = Path.Combine(dataFolder, "License.en-US.rtf");
            string productMsi = project.BuildMsi();

            project.Language    = "zh-CN";
            project.LicenceFile = Path.Combine(dataFolder, "License.zh-CN.rtf");
            string mstFile = BuildLanguageTransformEx(project, productMsi, project.Language, @"Localization\zh-CN.wxl", platformString);

            productMsi.EmbedTransform(mstFile);
            using (var database = new Database(productMsi, DatabaseOpenMode.Direct))
            {
                database.SummaryInfo.Template = platformString2 + BA.Languages.ToLcidList();
            }

            return(productMsi);
        }