Ejemplo n.º 1
0
        public HttpResponseMessage GetDeploymentScript()
        {
            using (_tracer.Step("DeploymentService.GetDeploymentScript"))
            {
                if (!_deploymentManager.GetResults().Any())
                {
                    throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Need to deploy website to get deployment script."));
                }

                string deploymentScriptContent = _deploymentManager.GetDeploymentScriptContent();

                if (deploymentScriptContent == null)
                {
                    throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Operation only supported if not using a custom deployment script"));
                }

                HttpResponseMessage response = Request.CreateResponse();
                response.Content = ZipStreamContent.Create("deploymentscript.zip", _tracer, zip =>
                {
                    // Add deploy.cmd to zip file
                    zip.AddFile(DeploymentManager.DeploymentScriptFileName, deploymentScriptContent);

                    // Add .deployment to cmd file
                    zip.AddFile(DeploymentSettingsProvider.DeployConfigFile, "[config]\ncommand = {0}\n".FormatInvariant(DeploymentManager.DeploymentScriptFileName));
                });

                return(response);
            }
        }