Ejemplo n.º 1
0
        private XmlClass CreateFromXml(XmlElement node)
        {
            switch (node.LocalName)
            {
            case "configuration":
                return(Configuration.CreateFromXml(node));

            case "component":
                return(Component.CreateFromXml(node));

            case "installedcheck":
                return(InstalledCheck.CreateFromXml(node));

            case "installedcheckoperator":
                return(InstalledCheckOperator.CreateFromXml(node));

            case "download":
                return(Download.CreateFromXml(node));

            case "downloaddialog":
                return(DownloadDialog.CreateFromXml(node));

            case "embedfile":
                return(EmbedFile.CreateFromXml(node));

            case "embedfolder":
                return(EmbedFolder.CreateFromXml(node));

            case "control":
                return(Control.CreateFromXml(node));

            default:
                throw new Exception(string.Format("Unsupported node: {0}", node.LocalName));
            }
        }
Ejemplo n.º 2
0
        public static EmbedFile CreateFromXml(XmlElement element)
        {
            EmbedFile result = new EmbedFile();

            result.FromXml(element);
            return(result);
        }
 public void TestGetFilesSourceAppPath()
 {
     EmbedFile embedFile = new EmbedFile();
     embedFile.sourcefilepath = @"#APPPATH\InstallerLibUnitTests.dll";
     embedFile.targetfilepath = @"#APPPATH\InstallerLibUnitTests.dll";
     string supportdir = Environment.CurrentDirectory;
     Dictionary<string, EmbedFileCollection> embedFileCollection = embedFile.GetFiles(string.Empty, supportdir);
     Assert.AreEqual(1, embedFileCollection.Count);
     Assert.AreEqual(Path.Combine(Environment.CurrentDirectory, "InstallerLibUnitTests.dll"), embedFileCollection[string.Empty][0].fullpath);
     Assert.AreEqual("InstallerLibUnitTests.dll", embedFileCollection[string.Empty][0].relativepath);
 }
 public void TestGetFilesNoTargetPath()
 {
     EmbedFile embedFile = new EmbedFile();
     embedFile.sourcefilepath = Path.Combine(Environment.CurrentDirectory, @"InstallerLibUnitTests.dll");
     string supportdir = @"C:\SupportFiles\SupportFile";
     Dictionary<string, EmbedFileCollection> embedFileCollection = embedFile.GetFiles(string.Empty, supportdir);
     Assert.AreEqual(1, embedFileCollection.Count);
     Assert.AreEqual(1, embedFileCollection[string.Empty].Count);
     Assert.AreEqual(embedFile.sourcefilepath, embedFileCollection[string.Empty][0].fullpath);
     Assert.AreEqual(@"InstallerLibUnitTests.dll", embedFileCollection[string.Empty][0].relativepath);
 }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
 public static EmbedFile CreateFromXml(XmlElement element)
 {
     EmbedFile result = new EmbedFile();
     result.FromXml(element);
     return result;
 }