Beispiel #1
0
        public void TestExtractCab()
        {
            Console.WriteLine("TestExtractCab");

            // create a self-extracting bootstrapper
            ConfigFile         configFile         = new ConfigFile();
            SetupConfiguration setupConfiguration = new SetupConfiguration();

            configFile.Children.Add(setupConfiguration);
            InstallerLinkerArguments args = new InstallerLinkerArguments();

            args.config = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml");
            Console.WriteLine("Writing '{0}'", args.config);
            configFile.SaveAs(args.config);
            args.embed      = true;
            args.apppath    = Path.GetTempPath();
            args.embedFiles = new string[] { Path.GetFileName(args.config) };
            args.output     = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".exe");
            args.template   = dotNetInstallerExeUtils.Executable;
            Console.WriteLine("Linking '{0}'", args.output);
            InstallerLinkerExeUtils.CreateInstaller(args);
            Assert.IsTrue(File.Exists(args.output));

            // execute dotNetInstaller
            Assert.AreEqual(0, dotNetInstallerExeUtils.Run(args.output, "/ExtractCab"));

            // this should have created a directory called SupportFiles in the current directory
            string supportFilesPath = Path.Combine(Path.GetDirectoryName(args.output), "SupportFiles");

            Console.WriteLine("Checking {0}", supportFilesPath);
            Assert.IsTrue(Directory.Exists(supportFilesPath), string.Format("Missing {0}", supportFilesPath));
            File.Delete(args.config);
            File.Delete(args.output);
            Directory.Delete(supportFilesPath, true);
        }
Beispiel #2
0
        public void TestDisplayCab()
        {
            Console.WriteLine("TestDisplayCab");

            // create a self-extracting bootstrapper
            ConfigFile         configFile         = new ConfigFile();
            SetupConfiguration setupConfiguration = new SetupConfiguration();

            configFile.Children.Add(setupConfiguration);
            InstallerLinkerArguments args = new InstallerLinkerArguments();

            args.config = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml");
            Console.WriteLine("Writing '{0}'", args.config);
            configFile.SaveAs(args.config);
            args.embed   = true;
            args.apppath = Path.GetTempPath();

            // args.embedFiles = new string[] { Path.GetFileName(args.config) };
            args.output   = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".exe");
            args.template = dotNetInstallerExeUtils.Executable;
            Console.WriteLine("Linking '{0}'", args.output);
            InstallerLinkerExeUtils.CreateInstaller(args);
            Assert.IsTrue(File.Exists(args.output));

            // execute dotNetInstaller
            Assert.AreEqual(0, dotNetInstallerExeUtils.Run(args.output, "/DisplayCab /qb"));
            File.Delete(args.config);
            File.Delete(args.output);
        }
Beispiel #3
0
        public void TestExtractCabTwoComponentsSameName()
        {
            Console.WriteLine("TestExtractCabTwoComponentsSameName");

            InstallerLinkerArguments args = new InstallerLinkerArguments();

            args.config = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml");
            Console.WriteLine("Writing '{0}'", args.config);
            args.embed    = true;
            args.apppath  = Path.GetTempPath();
            args.output   = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".exe");
            args.template = dotNetInstallerExeUtils.Executable;

            // create a self-extracting bootstrapper
            ConfigFile         configFile         = new ConfigFile();
            SetupConfiguration setupConfiguration = new SetupConfiguration();

            configFile.Children.Add(setupConfiguration);

            for (int i = 0; i < 2; i++)
            {
                ComponentCmd component = new ComponentCmd();
                component.id = "component";
                setupConfiguration.Children.Add(component);
                EmbedFile embedfile = new EmbedFile();
                embedfile.sourcefilepath = args.config;
                embedfile.targetfilepath = string.Format("component{0}\\file.xml", i);
                component.Children.Add(embedfile);
            }

            configFile.SaveAs(args.config);
            Console.WriteLine("Linking '{0}'", args.output);
            InstallerLinkerExeUtils.CreateInstaller(args);
            Assert.IsTrue(File.Exists(args.output));

            // execute dotNetInstaller
            Assert.AreEqual(0, dotNetInstallerExeUtils.Run(args.output, "/ExtractCab"));

            // this should have created a directory called SupportFiles in the current directory
            string supportFilesPath = Path.Combine(Path.GetDirectoryName(args.output), "SupportFiles");

            Console.WriteLine("Checking {0}", supportFilesPath);
            Assert.IsTrue(Directory.Exists(supportFilesPath), string.Format("Missing {0}", supportFilesPath));
            Assert.IsTrue(Directory.Exists(supportFilesPath + @"\component0"));
            Assert.IsTrue(File.Exists(supportFilesPath + @"\component0\file.xml"));
            Assert.IsTrue(Directory.Exists(supportFilesPath + @"\component1"));
            Assert.IsTrue(File.Exists(supportFilesPath + @"\component1\file.xml"));
            File.Delete(args.config);
            File.Delete(args.output);
            Directory.Delete(supportFilesPath, true);
        }
Beispiel #4
0
        public void TestExtractAndRunCabPerComponent()
        {
            Console.WriteLine("TestExtractAndRunCabPerComponent");

            InstallerLinkerArguments args = new InstallerLinkerArguments();

            args.config = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml");
            Console.WriteLine("Writing '{0}'", args.config);
            args.embed    = true;
            args.apppath  = Path.GetTempPath();
            args.output   = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".exe");
            args.template = dotNetInstallerExeUtils.Executable;

            // create a self-extracting bootstrapper
            ConfigFile         configFile         = new ConfigFile();
            SetupConfiguration setupConfiguration = new SetupConfiguration();

            setupConfiguration.cab_path            = Path.Combine(Path.GetTempPath(), "testExtractAndRunCabPerComponent");
            setupConfiguration.cab_path_autodelete = false;
            configFile.Children.Add(setupConfiguration);
            ComponentCmd component = new ComponentCmd();

            component.command          = "cmd.exe /C copy \"#CABPATH\\component\\before.xml\" \"#CABPATH\\component\\after.xml\"";
            component.required_install = true;
            setupConfiguration.Children.Add(component);
            EmbedFile embedfile = new EmbedFile();

            embedfile.sourcefilepath = args.config;
            embedfile.targetfilepath = @"component\before.xml";
            component.Children.Add(embedfile);
            configFile.SaveAs(args.config);
            Console.WriteLine("Linking '{0}'", args.output);
            InstallerLinkerExeUtils.CreateInstaller(args);
            Assert.IsTrue(File.Exists(args.output));

            // execute dotNetInstaller
            string logfile = Path.Combine(Path.GetTempPath(), "testExtractAndRunCabPerComponent.log");

            Console.WriteLine("Log: {0}", logfile);
            Assert.AreEqual(0, dotNetInstallerExeUtils.Run(args.output, string.Format("/qb /log /logfile \"{0}\"", logfile)));
            string extractedComponentPath = Path.Combine(setupConfiguration.cab_path, "component");

            Console.WriteLine("Checking {0}", extractedComponentPath);
            Assert.IsTrue(Directory.Exists(extractedComponentPath), string.Format("Missing {0}", extractedComponentPath));
            Assert.IsTrue(File.Exists(Path.Combine(Path.GetTempPath(), @"testExtractAndRunCabPerComponent\component\before.xml")));
            Assert.IsTrue(File.Exists(Path.Combine(Path.GetTempPath(), @"testExtractAndRunCabPerComponent\component\after.xml")));
            File.Delete(args.config);
            File.Delete(args.output);
            Directory.Delete(setupConfiguration.cab_path, true);
            File.Delete(logfile);
        }
Beispiel #5
0
        public void TestUserControlLicense()
        {
            Console.WriteLine("TestUserControlLicense");

            string configFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml");

            // a configuration with a license agreement control
            ConfigFile         configFile         = new ConfigFile();
            SetupConfiguration setupConfiguration = new SetupConfiguration();

            configFile.Children.Add(setupConfiguration);
            ControlLicense license = new ControlLicense();

            license.Accepted    = true;
            license.ResourceId  = "MY_RES_LICENSE";
            license.LicenseFile = configFilename;
            setupConfiguration.Children.Add(license);
            ComponentCmd cmd = new ComponentCmd();

            cmd.command          = "cmd.exe /C exit /b [MY_RES_LICENSE]";
            cmd.required_install = true;
            setupConfiguration.Children.Add(cmd);

            // save config file
            Console.WriteLine("Writing '{0}'", configFilename);
            configFile.SaveAs(configFilename);

            // create a setup with the license file
            InstallerLinkerArguments args = new InstallerLinkerArguments();

            args.config   = configFilename;
            args.output   = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".exe");
            args.template = dotNetInstallerExeUtils.Executable;
            Console.WriteLine("Linking '{0}'", args.output);
            InstallerLinkerExeUtils.CreateInstaller(args);
            Assert.IsTrue(File.Exists(args.output));

            // execute dotNetInstaller
            Assert.AreEqual(1, dotNetInstallerExeUtils.Run(args.output, "/q"));
            File.Delete(args.config);
            File.Delete(args.output);
        }
Beispiel #6
0
        public void TestUserControlRadioButtonHtmlValues()
        {
            Console.WriteLine("TestUserControlRadioButtonHtmlValues");

            bool usingHtmlInstaller = dotNetInstallerExeUtils.Executable.EndsWith("htmlInstaller.exe");

            if (!usingHtmlInstaller)
            {
                return;
            }

            // a configuration with a checkbox control
            ConfigFile         configFile         = new ConfigFile();
            SetupConfiguration setupConfiguration = new SetupConfiguration();

            setupConfiguration.auto_start = true;
            setupConfiguration.failed_exec_command_continue = string.Empty;
            setupConfiguration.auto_close_on_error          = true;
            configFile.Children.Add(setupConfiguration);
            ControlEdit edit = new ControlEdit();

            edit.Text = "3";
            edit.Id   = "edit1";
            setupConfiguration.Children.Add(edit);
            ComponentCmd cmd = new ComponentCmd();

            cmd.command          = "cmd.exe /C exit /b [edit1]1";
            cmd.required_install = true;
            setupConfiguration.Children.Add(cmd);

            // save config file
            InstallerLinkerArguments args = new InstallerLinkerArguments();

            args.config = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml");
            Console.WriteLine("Writing '{0}'", args.config);
            configFile.SaveAs(args.config);

            // create HTML directory
            string htmlPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            Directory.CreateDirectory(htmlPath);
            string htmlIndexFilename = Path.Combine(htmlPath, "index.html");

            File.WriteAllText(
                htmlIndexFilename,
                @"<html><head><title></title></head><body>
                                <input type=""radio"" id=""edit1"" name=""edit1"" value=""4"" checked=""checked"" />
                                <input type=""radio"" id=""edit1"" name=""edit1"" value=""2"" />
                                <input id=""button_install"" type=""button"" value=""Install"" />
                                </body></html>");

            // link the install executable
            args.htmlFiles  = new string[] { htmlPath };
            args.embed      = true;
            args.apppath    = Path.GetTempPath();
            args.embedFiles = new string[] { Path.GetFileName(args.config) };
            args.output     = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".exe");
            args.template   = dotNetInstallerExeUtils.Executable;
            Console.WriteLine("Linking '{0}'", args.output);
            InstallerLinkerExeUtils.CreateInstaller(args);
            Assert.IsTrue(File.Exists(args.output));

            // execute dotNetInstaller
            dotNetInstallerExeUtils.RunOptions runOptions = new dotNetInstallerExeUtils.RunOptions();
            runOptions.autostart = true;
            runOptions.quiet     = false;
            Assert.AreEqual(41, dotNetInstallerExeUtils.Run(args.output, runOptions.CommandLineArgs));
            File.Delete(args.config);
            Directory.Delete(args.htmlFiles[0], true);
        }