public GeneratorActionResult RollbackAction(GeneratorArguments arguments, Core.InputFields.ActionInputValues values, Dictionary <string, string> parameters)
        {
            var editHostsFile = values.GetBool("EditHostsFile");

            if (editHostsFile)
            {
                if (System.IO.File.Exists(string.Concat(HostFileWriter.HostFilePath, ".backup")))
                {
                    // Replace backup
                    System.IO.File.WriteAllText(HostFileWriter.HostFilePath,
                                                System.IO.File.ReadAllText(string.Concat(HostFileWriter.HostFilePath, ".backup"), Encoding.UTF8),
                                                Encoding.UTF8);
                }
            }

            return(new GeneratorActionResult(true, ""));
        }
        public GeneratorActionResult ExecuteAction(GeneratorArguments arguments, Core.InputFields.ActionInputValues values, Dictionary <string, string> parameters)
        {
            var editHostsFile = values.GetBool("EditHostsFile");
            var hostName      = values.GetString("HostName");

            if (editHostsFile)
            {
                // Create backup
                System.IO.File.WriteAllText(string.Concat(HostFileWriter.HostFilePath, ".backup"),
                                            System.IO.File.ReadAllText(HostFileWriter.HostFilePath, Encoding.UTF8),
                                            Encoding.UTF8);

                var hostEditor = new HostFileWriter();

                hostEditor.AddOrUpdateEntry(hostName, "127.0.0.1", String.Concat("Dev URL for ", arguments.Name));

                hostEditor.Save();
            }

            return(new GeneratorActionResult(true, ""));
        }
Beispiel #3
0
        public GeneratorActionResult ExecuteAction(GeneratorArguments arguments, Core.InputFields.ActionInputValues values, Dictionary <string, string> parameters)
        {
            var registerIis         = values.GetBool("RegisterIis");
            var hosttName           = values.GetString("HostName");
            var location            = values.GetString("DestinationFolder");
            var umbracoRelativePath = parameters["umbracoRelativePath"];

            foreach (var renameWord in arguments.TemplateInformation.Renames)
            {
                umbracoRelativePath = StringHelpers.ReplaceEx(umbracoRelativePath, renameWord.Key, renameWord.Value);
            }

            if (registerIis)
            {
                // Get IIS reference
                var serverManager = new ServerManager();

                // Create new AppPool or use existing
                var appPool = serverManager.ApplicationPools.FirstOrDefault(x => x.Name == arguments.Name) ??
                              serverManager.ApplicationPools.Add(arguments.Name);

                // Umbraco is .NET 4.0
                appPool.ManagedRuntimeVersion = "v4.0";

                // Add site and configure
                var physicalPath = System.IO.Path.Combine(location, umbracoRelativePath);
                serverManager.Sites.Add(arguments.Name, physicalPath, 80);

                serverManager.Sites[arguments.Name].ApplicationDefaults.ApplicationPoolName = arguments.Name;
                serverManager.Sites[arguments.Name].Bindings.Clear();
                serverManager.Sites[arguments.Name].Bindings.Add("*:80:" + hosttName, "http");
                serverManager.Sites[arguments.Name].ServerAutoStart = true;

                // Commit
                serverManager.CommitChanges();
            }

            return(new GeneratorActionResult(true, ""));
        }