当前位置: 首页>>代码示例>>C#>>正文


C# ConfigFile.SaveAs方法代码示例

本文整理汇总了C#中InstallerLib.ConfigFile.SaveAs方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigFile.SaveAs方法的具体用法?C# ConfigFile.SaveAs怎么用?C# ConfigFile.SaveAs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在InstallerLib.ConfigFile的用法示例。


在下文中一共展示了ConfigFile.SaveAs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestDefaultSelectionInstall

        public void TestDefaultSelectionInstall()
        {
            Console.WriteLine("TestDefaultSelectionInstall");

            ConfigFile configFile = new ConfigFile();
            // setup configuration
            SetupConfiguration setupConfiguration = new SetupConfiguration();
            configFile.Children.Add(setupConfiguration);
            // dummy component 1
            ComponentCmd component1 = new ComponentCmd();
            setupConfiguration.Children.Add(component1);
            component1.command = "cmd.exe /C exit /b 57";
            component1.required_install = true;
            component1.selected_install = false;
            // dummy component 2
            ComponentCmd component2 = new ComponentCmd();
            setupConfiguration.Children.Add(component2);
            component2.command = "cmd.exe /C exit /b 42";
            component2.required_install = true;
            component2.selected_install = true;
            // second component is selected and runs, not the first one
            string configFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml");
            Console.WriteLine("Writing '{0}'", configFilename);
            configFile.SaveAs(configFilename);
            dotNetInstallerExeUtils.RunOptions options = new dotNetInstallerExeUtils.RunOptions(configFilename);
            Assert.AreEqual(42, dotNetInstallerExeUtils.Run(options));
            // first component is selected and runs
            component1.selected_install = true;
            Console.WriteLine("Writing '{0}'", configFilename);
            configFile.SaveAs(configFilename);
            Assert.AreEqual(57, dotNetInstallerExeUtils.Run(options));
            File.Delete(configFilename);
        }
开发者ID:ramiklein,项目名称:dotnetinstaller,代码行数:33,代码来源:SelectionUnitTests.cs

示例2: TestLoadMSLU

        public void TestLoadMSLU()
        {
            Console.WriteLine("TestLoadUnicows");

            if (File.Exists(dotNetInstallerExeUtils.RunOptions.DefaultLogFile))
                File.Delete(dotNetInstallerExeUtils.RunOptions.DefaultLogFile);
            ConfigFile configFile = new ConfigFile();
            SetupConfiguration setupConfiguration = new SetupConfiguration();
            configFile.Children.Add(setupConfiguration);
            string configFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml");
            Console.WriteLine("Writing '{0}'", configFilename);
            configFile.SaveAs(configFilename);
            dotNetInstallerExeUtils.RunOptions options = new dotNetInstallerExeUtils.RunOptions(configFilename);
            options.loadMSLU = true;
            Assert.AreEqual(0, dotNetInstallerExeUtils.Run(options));
            File.Delete(configFilename);
            string[] logLines = File.ReadAllLines(dotNetInstallerExeUtils.RunOptions.DefaultLogFile);
            Console.WriteLine(logLines[0]);
            Assert.IsTrue(logLines[0].Contains("Loaded MSLU:"));
            string[] msluLine = logLines[0].Split(":".ToCharArray());
            string msluAddress = msluLine[msluLine.Length - 1].Trim();
            Console.WriteLine("MSLU loaded at: " + msluAddress);
            Assert.IsTrue(Int32.Parse(msluAddress, System.Globalization.NumberStyles.HexNumber) > 0);
            File.Delete(dotNetInstallerExeUtils.RunOptions.DefaultLogFile);
        }
开发者ID:Jairajp1992,项目名称:dotnetinstaller,代码行数:25,代码来源:MSLUUnitTests.cs

示例3: Main

        public static int Main(string[] args)
        {
            int rc = 0;
            Console.WriteLine("InstallerConfig: dotNetInstaller configuration (re)writer ({0})", Assembly.GetExecutingAssembly().GetName().Version);
            Console.WriteLine();

            InstallerConfigArguments i_args = new InstallerConfigArguments();
            if (Parser.ParseArgumentsWithUsage(args, i_args))
            {
                try
                {
                    ConfigFile configFile = new ConfigFile();
                    configFile.Load(i_args.configfile);
                    configFile.SaveAs(string.IsNullOrEmpty(i_args.outputfile)
                        ? i_args.configfile
                        : i_args.outputfile);
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine("ERROR: {0}", ex.Message);
#if DEBUG
                    Console.Error.WriteLine(ex.StackTrace);
#endif
                    rc = -2;
                }
            }
            else
            {
                rc = -1;
            }

            return rc;
        }
开发者ID:Jairajp1992,项目名称:dotnetinstaller,代码行数:33,代码来源:Program.cs

示例4: TestRebootExitCode

        public void TestRebootExitCode()
        {
            Console.WriteLine("TestRebootExitCode");

            // reboot exit code doesn't override a previous error
            ConfigFile configFile = new ConfigFile();
            SetupConfiguration setupConfiguration = new SetupConfiguration();
            configFile.Children.Add(setupConfiguration);
            ComponentCmd cmd_error = new ComponentCmd();
            cmd_error.command = "cmd.exe /C exit /b 42";
            cmd_error.required_install = true;
            cmd_error.allow_continue_on_error = true;
            cmd_error.default_continue_on_error = true;
            setupConfiguration.Children.Add(cmd_error);
            ComponentCmd cmd_reboot = new ComponentCmd();
            cmd_reboot.command = "cmd.exe /C exit /b 3010";
            cmd_error.required_install = true;
            cmd_reboot.returncodes_reboot = "3010";
            setupConfiguration.Children.Add(cmd_reboot);
            string configFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml");
            Console.WriteLine("Writing '{0}'", configFilename);
            configFile.SaveAs(configFilename);
            Assert.AreEqual(42, dotNetInstallerExeUtils.Run(configFilename));
            File.Delete(configFilename);
            dotNetInstallerExeUtils.DisableRunOnReboot();
        }
开发者ID:Jairajp1992,项目名称:dotnetinstaller,代码行数:26,代码来源:RebootUnitTests.cs

示例5: TestAutoStart

        public void TestAutoStart()
        {
            Console.WriteLine("TestAutoStart");

            ConfigFile configFile = new ConfigFile();
            // setup configuration
            SetupConfiguration setupConfiguration = new SetupConfiguration();
            setupConfiguration.auto_start = true;
            setupConfiguration.auto_close_if_installed = true;
            setupConfiguration.installation_completed = string.Empty;
            setupConfiguration.installation_none = string.Empty;
            configFile.Children.Add(setupConfiguration);
            // marker that makes installed check succeeed after installation
            string markerFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            // dummy component
            ComponentCmd component = new ComponentCmd();
            setupConfiguration.Children.Add(component);
            component.command = string.Format("cmd.exe /C dir > \"{0}\"", markerFilename);
            InstalledCheckFile check = new InstalledCheckFile();
            check.filename = markerFilename;
            check.comparison = installcheckfile_comparison.exists;
            component.Children.Add(check);
            // configuration
            component.installcompletemessage = string.Empty;
            string configFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml");
            Console.WriteLine("Writing '{0}'", configFilename);
            configFile.SaveAs(configFilename);
            dotNetInstallerExeUtils.RunOptions options = new dotNetInstallerExeUtils.RunOptions(configFilename);
            options.quiet = false;
            options.reboot = false;
            Assert.AreEqual(0, dotNetInstallerExeUtils.Run(options));
            Assert.IsTrue(File.Exists(markerFilename));
            File.Delete(configFilename);
            File.Delete(markerFilename);
        }
开发者ID:Jairajp1992,项目名称:dotnetinstaller,代码行数:35,代码来源:AutoStartUnitTests.cs

示例6: TestAllArgCmd

        public void TestAllArgCmd()
        {
            Console.WriteLine("TestAllArgCmd");

            ConfigFile configFile = new ConfigFile();
            // setup configuration
            SetupConfiguration setupConfiguration = new SetupConfiguration();
            configFile.Children.Add(setupConfiguration);
            ComponentCmd component1 = new ComponentCmd();
            setupConfiguration.Children.Add(component1);
            component1.id = "cmd1";
            component1.display_name = "command 1";
            component1.command = "cmd.exe /C exit /b ";
            component1.required_install = true;
            ComponentCmd component2 = new ComponentCmd();
            setupConfiguration.Children.Add(component2);
            component2.id = "cmd2";
            component2.display_name = "command 2";
            component2.command = "cmd.exe /C exit /b ";
            component2.required_install = true;
            string configFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml");
            Console.WriteLine("Writing '{0}'", configFilename);
            configFile.SaveAs(configFilename);
            dotNetInstallerExeUtils.RunOptions options = new dotNetInstallerExeUtils.RunOptions(configFilename);
            options.args = "/ComponentArgs *:\"23\"";
            Assert.AreEqual(23, dotNetInstallerExeUtils.Run(options));
            File.Delete(configFilename);
        }
开发者ID:Jairajp1992,项目名称:dotnetinstaller,代码行数:28,代码来源:ComponentArgsUnitTests.cs

示例7: TestDisplayCab

        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);
        }
开发者ID:Jairajp1992,项目名称:dotnetinstaller,代码行数:25,代码来源:CabUnitTests.cs

示例8: TestComponentWithoutCheck

 public void TestComponentWithoutCheck()
 {
     // a configuration with an optional component, complete command is executed
     ConfigFile configFile = new ConfigFile();
     SetupConfiguration setupConfiguration = new SetupConfiguration();
     string markerFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
     setupConfiguration.supports_uninstall = false; // otherwise would automatically switch to uninstall
     setupConfiguration.complete_command = string.Format("cmd.exe /C dir > \"{0}.ui\"", markerFilename);
     setupConfiguration.complete_command_basic = string.Format("cmd.exe /C dir > \"{0}.basic\"", markerFilename);
     setupConfiguration.complete_command_silent = string.Format("cmd.exe /C dir > \"{0}.silent\"", markerFilename);
     configFile.Children.Add(setupConfiguration);
     // required component that will run, but has no installed check
     ComponentCmd cmd1 = new ComponentCmd();
     setupConfiguration.Children.Add(cmd1);
     cmd1.command = "cmd.exe /C exit /b 0";
     // save config file
     string configFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml");
     Console.WriteLine("Writing '{0}'", configFilename);
     configFile.SaveAs(configFilename);
     // execute dotNetInstaller
     Assert.AreEqual(0, dotNetInstallerExeUtils.Run(configFilename));
     File.Delete(configFilename);
     Assert.IsFalse(File.Exists(markerFilename + ".silent"));
     File.Delete(markerFilename);
 }
开发者ID:Jairajp1992,项目名称:dotnetinstaller,代码行数:25,代码来源:CompleteCommandUnitTests.cs

示例9: TestLogCommandLineOverwritesConfigFile

        public void TestLogCommandLineOverwritesConfigFile()
        {
            Console.WriteLine("TestLogCommandLineOverwritesConfigFile");

            if (File.Exists(dotNetInstallerExeUtils.RunOptions.DefaultLogFile))
                File.Delete(dotNetInstallerExeUtils.RunOptions.DefaultLogFile);
            ConfigFile configFile = new ConfigFile();
            configFile.log_enabled = true;
            configFile.log_file = Path.Combine(Path.GetTempPath(), "TestLogConfigSpecified.log");
            if (File.Exists(configFile.log_file))
                File.Delete(configFile.log_file);
            SetupConfiguration setupConfiguration = new SetupConfiguration();
            configFile.Children.Add(setupConfiguration);
            string configFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml");
            Console.WriteLine("Writing '{0}'", configFilename);
            configFile.SaveAs(configFilename);
            dotNetInstallerExeUtils.RunOptions options = new dotNetInstallerExeUtils.RunOptions(configFilename);
            options.log = true;
            options.logfile = dotNetInstallerExeUtils.RunOptions.DefaultLogFile;
            Assert.AreEqual(0, dotNetInstallerExeUtils.Run(options));
            File.Delete(configFilename);
            Assert.IsTrue(File.Exists(dotNetInstallerExeUtils.RunOptions.DefaultLogFile));
            Assert.IsFalse(File.Exists(configFile.log_file));
            File.Delete(configFile.log_file);
        }
开发者ID:Jairajp1992,项目名称:dotnetinstaller,代码行数:25,代码来源:LoggingUnitTests.cs

示例10: TestConfigReadWrite

 public void TestConfigReadWrite()
 {
     // generate a configuration with as many changed values as possible, write/read and compare
     // ensures that all fields are property read and written to/from configuration files
     string configFilenameOriginal = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml");
     string configFilenameLoaded = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml");
     // original file
     ConfigFile configFileOriginal = new ConfigFile();
     GenerateChildren(configFileOriginal);
     Console.WriteLine("Writing '{0}'", configFilenameOriginal);
     configFileOriginal.SaveAs(configFilenameOriginal);
     // loaded file
     ConfigFile configFileLoaded = new ConfigFile();
     configFileLoaded.Load(configFilenameOriginal);
     Console.WriteLine("Writing '{0}'", configFilenameLoaded);
     configFileLoaded.SaveAs(configFilenameLoaded);
     // compare
     XmlDocument originalXml = new XmlDocument();
     originalXml.Load(configFilenameOriginal);
     XmlDocument loadedXml = new XmlDocument();
     loadedXml.Load(configFilenameLoaded);
     // compare contents
     Assert.AreEqual(originalXml.OuterXml, loadedXml.OuterXml);
     // delete files on success, otherwise keep for diff
     File.Delete(configFilenameOriginal);
     File.Delete(configFilenameLoaded);
 }
开发者ID:Jairajp1992,项目名称:dotnetinstaller,代码行数:27,代码来源:ConfigFileTests.cs

示例11: HideComponentIfInstalled_WithComponentAlreadyInstalledDuringInstallSequence_HidesComponent

        public void HideComponentIfInstalled_WithComponentAlreadyInstalledDuringInstallSequence_HidesComponent()
        {
            string dotNetInstallerExeFilePath = dotNetInstallerExeUtils.Executable;

            bool usingHtmlInstaller = dotNetInstallerExeFilePath.EndsWith("htmlInstaller.exe");

            // create configuration file
            ConfigFile configFile = new ConfigFile();

            // add a setup configuration
            SetupConfiguration setupConfiguration = new SetupConfiguration();
            configFile.Children.Add(setupConfiguration);

            // add a component that is hidden if it's already installed
            ComponentCmd componentAlreadyInstalled = new ComponentCmd();
            componentAlreadyInstalled.hide_component_if_installed = true;
            setupConfiguration.Children.Add(componentAlreadyInstalled);

            // make the component appear to be already installed
            InstalledCheckFile existsCheck = new InstalledCheckFile();
            existsCheck.filename = dotNetInstallerExeUtils.Executable;
            existsCheck.comparison = installcheckfile_comparison.exists;
            componentAlreadyInstalled.Children.Add(existsCheck);

            // add another component that is not already installed
            ComponentCmd componentNotInstalled = new ComponentCmd();
            setupConfiguration.Children.Add(componentNotInstalled);

            // save the configuration file
            string configFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml");
            configFile.SaveAs(configFilename);

            // execute dotNetInstaller
            string arguments = string.Format("/ConfigFile {0}", configFilename);
            using (Application dotNetInstaller = Application.Launch(new ProcessStartInfo(dotNetInstallerExeFilePath, arguments)))
            {
                // get the main install window
                Window mainWindow = dotNetInstaller.GetWindow("APPLICATION_NAME Installer", InitializeOption.NoCache);

                if (usingHtmlInstaller)
                {
                    // get all the checkboxes in the window
                    IUIItem[] checkBoxes = mainWindow.GetMultiple(SearchCriteria.ByControlType(typeof(CheckBox)));

                    // assert that there's only one checkbox
                    Assert.AreEqual(1, checkBoxes.Length);
                    Assert.AreEqual("command1 ", checkBoxes[0].Name);
                }
                else
                {
                    // using dotNetInstaller
                    // get the components list box
                    ListBox componentsList = mainWindow.Get<ListBox>();

                    // assert that only one component is in the list
                    Assert.AreEqual(1, componentsList.Items.Count);
                    Assert.AreEqual("command1 ", componentsList.Items[0].Name);
                }
            }
        }
开发者ID:Jairajp1992,项目名称:dotnetinstaller,代码行数:60,代码来源:UIUnitTests.cs

示例12: TestRunFileConfiguration

 public void TestRunFileConfiguration()
 {
     ConfigFile configFile = new ConfigFile();
     SetupConfiguration setupConfiguration = new SetupConfiguration();
     configFile.Children.Add(setupConfiguration);
     string configFileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml");
     Console.WriteLine("Writing '{0}'", configFileName);
     configFile.SaveAs(configFileName);
     try
     {
         ProcessStartInfo pi = new ProcessStartInfo(InstallerEditorExeUtils.Executable, "\"" + configFileName + "\"");
         using (Application installerEditor = Application.Launch(pi))
         {
             string title = string.Format("Installer Editor - {0}", configFileName);
             Window mainWindow = installerEditor.GetWindow(title, InitializeOption.NoCache);
             Tree configurationTree = UIAutomation.Find<Tree>(mainWindow, "configurationTree");
             Assert.AreEqual("Config File", configurationTree.SelectedNode.Name);
             StatusStrip statusStrip = UIAutomation.Find<StatusStrip>(mainWindow, "statusStrip");
             WinFormTextBox statusLabel = (WinFormTextBox)statusStrip.Items[0];
             Assert.AreEqual(string.Format("Loaded {0}", configFileName), statusLabel.Text);
         }
     }
     finally
     {
         File.Delete(configFileName);
     }
 }
开发者ID:Jairajp1992,项目名称:dotnetinstaller,代码行数:27,代码来源:CommandLineParametersUnitTests.cs

示例13: TestLogAcceptsPathVariables

        public void TestLogAcceptsPathVariables()
        {
            Console.WriteLine("TestLogAcceptsPathVariables");

            string resolved_logfile = Path.Combine(Path.GetTempPath(), "TestLogAcceptsPathVariables.log");
            if (File.Exists(dotNetInstallerExeUtils.RunOptions.DefaultLogFile))
                File.Delete(dotNetInstallerExeUtils.RunOptions.DefaultLogFile);
            if (File.Exists(resolved_logfile))
                File.Delete(resolved_logfile);
            ConfigFile configFile = new ConfigFile();
            configFile.log_enabled = true;
            configFile.log_file = @"#TEMPPATH\TestLogAcceptsPathVariables.log";
            SetupConfiguration setupConfiguration = new SetupConfiguration();
            configFile.Children.Add(setupConfiguration);
            string configFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml");
            Console.WriteLine("Writing '{0}'", configFilename);
            configFile.SaveAs(configFilename);
            dotNetInstallerExeUtils.RunOptions options = new dotNetInstallerExeUtils.RunOptions(configFilename);
            options.log = false;
            options.logfile = string.Empty;
            Assert.AreEqual(0, dotNetInstallerExeUtils.Run(options));
            File.Delete(configFilename);
            Assert.IsTrue(File.Exists(resolved_logfile), string.Format("Missing {0}", resolved_logfile));
            Assert.IsFalse(File.Exists(dotNetInstallerExeUtils.RunOptions.DefaultLogFile));
            File.Delete(resolved_logfile);
        }
开发者ID:Jairajp1992,项目名称:dotnetinstaller,代码行数:26,代码来源:LoggingUnitTests.cs

示例14: TestContinueOnError

        public void TestContinueOnError()
        {
            Console.WriteLine("TestContinueOnError");

            ConfigFile configFile = new ConfigFile();
            string markerFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            string markerFilename1 = string.Format("{0}.1", markerFilename);
            string markerFilename2 = string.Format("{0}.2", markerFilename);
            SetupConfiguration setupConfiguration = new SetupConfiguration();
            configFile.Children.Add(setupConfiguration);
            ComponentCmd cmd1 = new ComponentCmd();
            setupConfiguration.Children.Add(cmd1);
            cmd1.command = string.Format("cmd.exe /C dir > \"{0}\" & exit /b 1", markerFilename1);
            cmd1.required_install = true;
            ComponentCmd cmd2 = new ComponentCmd();
            setupConfiguration.Children.Add(cmd2);
            cmd2.command = string.Format("cmd.exe /C dir > \"{0}\" & exit /b 2", markerFilename2);
            cmd2.required_install = true;
            // save config file
            string configFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".xml");
            Console.WriteLine("Writing '{0}'", configFilename);
            configFile.SaveAs(configFilename);
            // execute dotNetInstaller
            Assert.AreEqual(1, dotNetInstallerExeUtils.Run(configFilename));
            Assert.IsTrue(File.Exists(markerFilename1));
            Assert.IsFalse(File.Exists(markerFilename2));
            File.Delete(markerFilename1);
            // allow continue on error (user prompted) -> no effect, this is a prompt that defaults to false in silent mode
            cmd1.allow_continue_on_error = true;
            cmd2.allow_continue_on_error = true;
            configFile.SaveAs(configFilename);
            Assert.AreEqual(1, dotNetInstallerExeUtils.Run(configFilename));
            Assert.IsTrue(File.Exists(markerFilename1));
            Assert.IsFalse(File.Exists(markerFilename2));
            File.Delete(markerFilename1);
            // continue on error by default -> continues on the first and the second component, returns the last error code
            cmd1.default_continue_on_error = true;
            cmd2.default_continue_on_error = true;
            configFile.SaveAs(configFilename);
            // the return code of the first failure is saved
            Assert.AreEqual(1, dotNetInstallerExeUtils.Run(configFilename));
            Assert.IsTrue(File.Exists(markerFilename1));
            Assert.IsTrue(File.Exists(markerFilename2));
            File.Delete(markerFilename1);
            File.Delete(markerFilename2);
            File.Delete(configFilename);
        }
开发者ID:Jairajp1992,项目名称:dotnetinstaller,代码行数:47,代码来源:ContinueOnErrorUnitTests.cs

示例15: TestPromptForOptionalNotSet

        public void TestPromptForOptionalNotSet()
        {
            Console.WriteLine("TestPromptForOptionalNotSet");

            // configuration with a required and optional component that will auto-start
            // and won't prompt or execute the optional component

            string markerFilename = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

            ConfigFile configFile = new ConfigFile();

            SetupConfiguration setupConfiguration = new SetupConfiguration();
            setupConfiguration.auto_start = true;
            setupConfiguration.auto_close_if_installed = true;
            setupConfiguration.prompt_for_optional_components = false;
            setupConfiguration.installation_completed = "";
            setupConfiguration.installation_none = "";
            configFile.Children.Add(setupConfiguration);

            // dummy required component
            ComponentCmd component_required = new ComponentCmd();
            setupConfiguration.Children.Add(component_required);
            component_required.required_install = true;
            component_required.supports_install = true;
            component_required.command = "dummy";

            InstalledCheckRegistry check_required = new InstalledCheckRegistry();
            check_required.fieldname = "";
            check_required.path = "SOFTWARE";
            check_required.comparison = installcheckregistry_comparison.exists;
            component_required.Children.Add(check_required);

            // dummy optional component
            ComponentCmd component_optional = new ComponentCmd();
            setupConfiguration.Children.Add(component_optional);
            component_optional.required_install = false;
            component_optional.supports_install = true;
            component_optional.command = string.Format("cmd.exe /C dir > \"{0}\"", markerFilename);

            InstalledCheckFile check_optional = new InstalledCheckFile();
            check_optional.filename = markerFilename;
            check_optional.comparison = installcheckfile_comparison.exists;
            component_optional.Children.Add(check_optional);

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

            // will not auto close since all components installed successfully
            dotNetInstallerExeUtils.RunOptions options = new dotNetInstallerExeUtils.RunOptions(configFilename);
            options.quiet = false;
            options.autostart = true;
            Assert.AreEqual(0, dotNetInstallerExeUtils.Run(options));

            Assert.IsFalse(File.Exists(markerFilename));

            File.Delete(configFilename);
        }
开发者ID:ramiklein,项目名称:dotnetinstaller,代码行数:58,代码来源:PromptForOptionalUnitTests.cs


注:本文中的InstallerLib.ConfigFile.SaveAs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。