protected override void DoPrepare() { EnvironmentInfo environmentInfo = GetEnvironmentInfo(); // create a step for downloading the artifacts var downloadArtifactsDeploymentStep = new DownloadArtifactsDeploymentStep( _artifactsRepository, _projectInfo, _projectConfigurationName, _projectConfigurationBuildId, GetTempDirPath()); AddSubTask(downloadArtifactsDeploymentStep); // create a step for extracting the artifacts var extractArtifactsDeploymentStep = new ExtractArtifactsDeploymentStep( environmentInfo, _projectInfo, _projectConfigurationName, _projectConfigurationBuildId, downloadArtifactsDeploymentStep.ArtifactsFilePath, GetTempDirPath()); AddSubTask(extractArtifactsDeploymentStep); if (_projectInfo.ArtifactsAreEnvironmentSpecific) { var binariesConfiguratorStep = new ConfigureBinariesStep( environmentInfo.ConfigurationTemplateName, GetTempDirPath()); AddSubTask(binariesConfiguratorStep); } foreach (string webServerMachineName in environmentInfo.WebServerMachineNames) { string webApplicationPhysicalPath = _iisManager.GetWebApplicationPath( webServerMachineName, string.Format("{0}/{1}", _projectInfo.IisSiteName, _projectInfo.WebAppName)); if (!string.IsNullOrEmpty(webApplicationPhysicalPath)) { string webApplicationNetworkPath = string.Format( "\\\\{0}\\{1}${2}", webServerMachineName, webApplicationPhysicalPath[0], webApplicationPhysicalPath.Substring(2)); if (Directory.Exists(webApplicationNetworkPath)) { var backupFilesDeploymentStep = new BackupFilesDeploymentStep(webApplicationNetworkPath); AddSubTask(backupFilesDeploymentStep); } } // create a step for creating a WebDeploy package // TODO IMM HI: add possibility to specify physical path on the target machine var createWebDeployPackageDeploymentStep = new CreateWebDeployPackageDeploymentStep( _msDeploy, extractArtifactsDeploymentStep.BinariesDirPath, _projectInfo.IisSiteName, _projectInfo.WebAppName); AddSubTask(createWebDeployPackageDeploymentStep); // create a step for deploying the WebDeploy package to the target machine var deployWebDeployPackageDeploymentStep = new DeployWebDeployPackageDeploymentStep( _msDeploy, createWebDeployPackageDeploymentStep.PackageFilePath, webServerMachineName); AddSubTask(deployWebDeployPackageDeploymentStep); // check if the app pool exists on the target machine if (!_iisManager.AppPoolExists(webServerMachineName, _projectInfo.AppPool.Name)) { // create a step for creating a new app pool var createAppPoolDeploymentStep = new CreateAppPoolDeploymentStep( _iisManager, webServerMachineName, _projectInfo.AppPool); AddSubTask(createAppPoolDeploymentStep); } // create a step for assigning the app pool to the web application var setAppPoolDeploymentStep = new SetAppPoolDeploymentStep( _iisManager, webServerMachineName, _projectInfo.IisSiteName, _projectInfo.WebAppName, _projectInfo.AppPool); AddSubTask(setAppPoolDeploymentStep); } }
protected override void DoPrepare() { EnvironmentInfo environmentInfo = GetEnvironmentInfo(); WebAppProjectInfo projectInfo = GetProjectInfo<WebAppProjectInfo>(); WebAppInputParams inputParams = (WebAppInputParams)DeploymentInfo.InputParams; if (inputParams.OnlyIncludedWebMachines != null) { if (!inputParams.OnlyIncludedWebMachines.Any()) { throw new DeploymentTaskException("If inputParams OnlyIncludedWebMachines has been specified, it must contain at least one web machine."); } string[] invalidMachineNames = inputParams.OnlyIncludedWebMachines .Except(environmentInfo.WebServerMachineNames) .ToArray(); if (invalidMachineNames.Any()) { throw new DeploymentTaskException(string.Format("Invalid web machines '{0}' have been specified.", string.Join(",", invalidMachineNames))); } } if (projectInfo == null) { throw new InvalidOperationException(string.Format("Project info must be of type '{0}'.", typeof(WebAppProjectInfo).FullName)); } // create a step for downloading the artifacts var downloadArtifactsDeploymentStep = new DownloadArtifactsDeploymentStep( projectInfo, DeploymentInfo, GetTempDirPath(), _artifactsRepository); AddSubTask(downloadArtifactsDeploymentStep); // create a step for extracting the artifacts var extractArtifactsDeploymentStep = new ExtractArtifactsDeploymentStep( projectInfo, environmentInfo, DeploymentInfo, downloadArtifactsDeploymentStep.ArtifactsFilePath, GetTempDirPath(), _fileAdapter, _zipFileAdapter); AddSubTask(extractArtifactsDeploymentStep); if (projectInfo.ArtifactsAreEnvironmentSpecific) { var binariesConfiguratorStep = new ConfigureBinariesStep( environmentInfo.ConfigurationTemplateName, GetTempDirPath()); AddSubTask(binariesConfiguratorStep); } WebAppProjectConfiguration configuration = environmentInfo.GetWebAppProjectConfiguration(projectInfo.Name); string webSiteName = configuration.WebSiteName; string webAppName = configuration.WebAppName; IisAppPoolInfo appPoolInfo = environmentInfo.GetAppPoolInfo(configuration.AppPoolId); IEnumerable<string> webMachinesToDeployTo = (inputParams.OnlyIncludedWebMachines ?? environmentInfo.WebServerMachineNames) .Distinct(); foreach (string webServerMachineName in webMachinesToDeployTo) { /* // TODO IMM HI: xxx we don't need this for now - should we parameterize this somehow? string webApplicationPhysicalPath = _iisManager.GetWebApplicationPath( webServerMachineName, string.Format("{0}/{1}", webSiteName, webAppName)); if (!string.IsNullOrEmpty(webApplicationPhysicalPath)) { string webApplicationNetworkPath = string.Format( "\\\\{0}\\{1}${2}", webServerMachineName, webApplicationPhysicalPath[0], webApplicationPhysicalPath.Substring(2)); if (Directory.Exists(webApplicationNetworkPath)) { var backupFilesDeploymentStep = new BackupFilesDeploymentStep( webApplicationNetworkPath); AddSubTask(backupFilesDeploymentStep); } } */ // create a step for creating a WebDeploy package // TODO IMM HI: add possibility to specify physical path on the target machine var createWebDeployPackageDeploymentStep = new CreateWebDeployPackageDeploymentStep( _msDeploy, new Lazy<string>(() => extractArtifactsDeploymentStep.BinariesDirPath), webSiteName, webAppName); AddSubTask(createWebDeployPackageDeploymentStep); // create a step for deploying the WebDeploy package to the target machine var deployWebDeployPackageDeploymentStep = new DeployWebDeployPackageDeploymentStep( _msDeploy, webServerMachineName, new Lazy<string>(() => createWebDeployPackageDeploymentStep.PackageFilePath)); AddSubTask(deployWebDeployPackageDeploymentStep); // check if the app pool exists on the target machine if (!_iisManager.AppPoolExists(webServerMachineName, appPoolInfo.Name)) { // create a step for creating a new app pool var createAppPoolDeploymentStep = new CreateAppPoolDeploymentStep( _iisManager, webServerMachineName, appPoolInfo); AddSubTask(createAppPoolDeploymentStep); } // create a step for assigning the app pool to the web application var setAppPoolDeploymentStep = new SetAppPoolDeploymentStep( _iisManager, webServerMachineName, webSiteName, appPoolInfo, webAppName); AddSubTask(setAppPoolDeploymentStep); } }