Esempio n. 1
0
        private static void CreateWebSiteIfNotExists()
        {
            var manager = new ServerManager();

            if (!manager.ApplicationPoolExists(Configuration.SiteName))
            {
                var pool = manager.ApplicationPools.Add(Configuration.SiteName);
                pool.ManagedRuntimeVersion = "v4.0";
                manager.CommitChanges();
            }
            else
            {
                ConsoleHelper.WriteLine(ConsoleColor.Yellow, string.Format("ApplicationPool {0} already exists, creation skiped", Configuration.SiteName));
            }

            if (!manager.SiteExists(Configuration.SiteName))
            {
                var site = manager.Sites.Add(Configuration.SiteName, Configuration.DeploymentPath, Configuration.SitePort);
                site.ApplicationDefaults.ApplicationPoolName = Configuration.SiteName;
                manager.CommitChanges();
            }
            else
            {
                ConsoleHelper.WriteLine(ConsoleColor.Yellow, string.Format("Site {0} already exists, creation skiped", Configuration.SiteName));
            }
        }