示例#1
0
        public static bool Uninstall(string rollBackPath, bool unattended, string setupName, string pluginDirs)
        {
            string template = string.Empty;

            if (!string.IsNullOrWhiteSpace(pluginDirs))
            {
                AssembliesManager.LoadAssembliesFrom(pluginDirs);
            }
            _setupFile = DeserializeRollback(rollBackPath);
            _setupFile.PluginsDir = pluginDirs;

            SingleWorkflowStep.Initialize(_setupFile);
            _setupFile.Undoing = true;
            _setupFile.Unattended = unattended;
            Console.WriteLine("Uninstall started.");

            /*for (int i = (_setupFile.Rollback.Count - 1); i >= 0; i--)
            {
                if (_setupFile.Rollback[i].NeedAdminRights)
                {
                    throw new AuthenticationException();
                }
            }*/
            for (int i = (_setupFile.Rollback.Count - 1); i >= 0; i--)
            {
                SingleWorkflowStep.ShowElementHelp(_setupFile.Rollback[i]);
                _setupFile.Rollback[i].Execute(ref template);
                _setupFile.Rollback[i].RunSteps(_setupFile.Rollback[i].WorkflowSteps, ref template);
                _setupFile.Rollback.RemoveAt(i);
            }
            Console.WriteLine("Uninstall completed.");
            return true;
        }
示例#2
0
        internal static SetupFile LoadTemplateFile(string templatePath, string pluginDirs, bool unattended)
        {
            _setupFile = new SetupFile(unattended);
            _setupFile.PluginsDir = pluginDirs;
            if (!string.IsNullOrWhiteSpace(_setupFile.PluginsDir))
            {
                AssembliesManager.LoadAssembliesFrom(_setupFile.PluginsDir);
            }
            SingleWorkflowStep.Initialize(_setupFile);
            _templatesDirectory = Path.GetDirectoryName(templatePath);
            _templatesDirectories.Add(_templatesDirectory);
            _xmlDoc = new XmlDocument(); //* create an xml document object.
            _xmlDoc.Load(templatePath); //* load the XML document from the specified file.

            /*var rootNode = _xmlDoc.GetElementsByTagName("root")[0];
            var rootConfig = rootNode.GetChildrenByTag("configs")[0];
            ExtractConfigs(rootConfig);

            var rootTemplates = rootNode.GetChildrenByTag("templates")[0];
            ExtractTemplates(rootTemplates);
            var baseTemplates = rootNode.GetChildrenByTag("baseTemplates")[0];
            ExtractBaseTemplates(baseTemplates);

            var workflow = rootNode.GetChildrenByTag("workflow")[0];
            ExtractWrokflow(workflow, _setupFile.WorkflowRoot);*/
            LoadRelativeXmlTemplate(_setupFile.WorkflowRoot, _xmlDoc);
            return _setupFile;
        }
示例#3
0
        public static bool Start(string templatePath, string destinationPath, string pluginDirs, bool unattended, 
			string rollBackPath = null, string sourcePath=null)
        {
            _destinationPath = destinationPath.TrimEnd(Path.DirectorySeparatorChar);
            _templatesDirectory = Path.GetDirectoryName(templatePath);
            _setupFile = TemplateFileLoader.LoadTemplateFile(templatePath,pluginDirs, unattended);
            _setupFile.SetKey("${SetupDirectory}",Directory.GetCurrentDirectory());
            _setupFile.SetKey("${TemplatesDirectory}", _templatesDirectory);
            _setupFile.SetKey("${TemplatePath}", templatePath);
            _setupFile.SetKey("${DestinationPath}", _destinationPath);
            if (string.IsNullOrEmpty(sourcePath))
            {
                sourcePath = _templatesDirectory;
            }
            _setupFile.SetKey("${SourcePath}", sourcePath);
            #if DEBUG
            _setupFile.SetKey("${Build}", "Debug");
            #else
            _setupFile.SetKey("${Build}", "Release");
            #endif
            return RunSetup(rollBackPath);
        }