Helps create app pools and websites.
Ejemplo n.º 1
0
        public object Post(TriggerDeployment request)
        {
            if (Request.Files.Length != 1)
            {
                throw new HttpError(HttpStatusCode.BadRequest, "Please add one (and just one) file to deploy.");
            }

            IISManager.CreateAppPool(request.AppPoolName, request.AppPoolUser, request.AppPoolPassword, request.RuntimeVersion, request.Overwrite);
            IISManager.CreateWebsite(request.WebsiteName, request.WebsitePhysicalPath, request.WebsitePort, request.AppPoolName, request.Overwrite);

            var uploadedPackageZip = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "package.zip");

            Request.Files[0].SaveTo(uploadedPackageZip);

            if (string.IsNullOrEmpty(request.AppRoot) || request.AppRoot == "/")
            {
                var targetPath = Path.Combine(request.WebsitePhysicalPath, "{0}_v{1}".Fmt(request.PackageId, request.PackageVersion));

                using (var zip = ZipFile.Read(uploadedPackageZip))
                {
                    zip.ForEach(z => z.Extract(targetPath, ExtractExistingFileAction.OverwriteSilently));
                }

                // the package is unpacked to the new destination, remap the website to the new version
                IISManager.MapWebsitePhysicalPath(request.WebsiteName, targetPath);
            }
            else
            {
                ////this lets you access your application with for example http://your-host/sub1/sub2/app
                if (!Directory.Exists(request.AppPhysicalPath))
                {
                    Directory.CreateDirectory(request.AppPhysicalPath);
                }

                var appTargetPath = Path.Combine(request.AppPhysicalPath, "{0}_v{1}".Fmt(request.PackageId, request.PackageVersion));

                using (var zip = ZipFile.Read(uploadedPackageZip))
                {
                    zip.ForEach(z => z.Extract(appTargetPath, ExtractExistingFileAction.OverwriteSilently));
                }

                ////ApplyBackupRetentionPolicy(request.AppPhysicalPath, request.AppName);

                var appFolderInWebsite = Path.Combine(request.WebsitePhysicalPath, request.AppRoot.Trim('/'));
                var appPath            = "{0}/{1}".Fmt(request.AppRoot.TrimEnd('/'), request.AppName);

                if (!Directory.Exists(appFolderInWebsite))
                {
                    Directory.CreateDirectory(appFolderInWebsite);
                }

                IISManager.CreateApplication(request.WebsiteName, appPath, appTargetPath);
            }

            return(new TriggerDeploymentResponse {
                Status = "OK"
            });
        }
Ejemplo n.º 2
0
        public void Post(RollbackDeployment request)
        {
            if (string.IsNullOrEmpty(request.AppName) && string.IsNullOrEmpty(request.AppRoot))
            {
                var websitePath = IISManager.GetWebsitePath(request.WebsiteName);

                IISManager.MapWebsitePhysicalPath(request.WebsiteName, Path.Combine(Directory.GetParent(websitePath).FullName, request.RollbackTarget));
            }
            else
            {
                IISManager.RollbackApplication(request.WebsiteName, request.AppRoot, request.AppName, request.RollbackTarget);
            }
        }
Ejemplo n.º 3
0
        public List <DeploymentInfo> Get(QueryDeployments request)
        {
            string path;

            if (!string.IsNullOrEmpty(request.AppName) && !string.IsNullOrEmpty(request.AppRoot))
            {
                path = Path.Combine(IISManager.GetApplicationPath(request.WebsiteName, request.AppRoot, request.AppName), "..");
            }
            else
            {
                path = Path.Combine(IISManager.GetWebsitePath(request.WebsiteName), "..");
            }

            var list = new List <DeploymentInfo>();

            new DirectoryInfo(path).GetDirectories().ForEach(d => list.Add(new DeploymentInfo {
                Name = d.Name
            }));

            return(list);
        }