protected override void DoPrepare() { EnvironmentInfo environmentInfo = GetEnvironmentInfo(); _projectInfo = GetProjectInfo<NtServiceProjectInfo>(); // 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, _directoryAdapter, _zipFileAdapter); AddSubTask(extractArtifactsDeploymentStep); if (_projectInfo.ArtifactsAreEnvironmentSpecific) { var binariesConfiguratorStep = new ConfigureBinariesStep( environmentInfo.ConfigurationTemplateName, GetTempDirPath()); AddSubTask(binariesConfiguratorStep); } bool deployToClusteredEnvironment = environmentInfo.EnableFailoverClusteringForNtServices; if (deployToClusteredEnvironment) { PostDiagnosticMessage("Will deploy to a clustered environment.", DiagnosticMessageType.Trace); if (string.IsNullOrEmpty(environmentInfo.GetFailoverClusterGroupNameForProject(DeploymentInfo.ProjectName))) { throw new InvalidOperationException(string.Format("Failover clustering for NT services is enabled for environment '{0}' but there is no cluster group mapping for project '{1}'.", environmentInfo.Name, DeploymentInfo.ProjectName)); } DoPrepareDeploymentToClusteredEnvironment( environmentInfo, new Lazy<string>(() => extractArtifactsDeploymentStep.BinariesDirPath)); } else { PostDiagnosticMessage("Will deploy to a non-clustered environment.", DiagnosticMessageType.Trace); DoPrepareDeploymentToStandardEnvironment( environmentInfo, new Lazy<string>(() => extractArtifactsDeploymentStep.BinariesDirPath)); } }
protected override void DoPrepare() { EnvironmentInfo environmentInfo = GetEnvironmentInfo(); _projectInfo = GetProjectInfo<PowerShellScriptProjectInfo>(); IEnumerable<string> targetMachineNames = _projectInfo.GetTargetMachines(environmentInfo); // 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, _directoryAdapter, _zipFileAdapter); AddSubTask(extractArtifactsDeploymentStep); if (_projectInfo.ArtifactsAreEnvironmentSpecific) { var binariesConfiguratorStep = new ConfigureBinariesStep( environmentInfo.ConfigurationTemplateName, GetTempDirPath()); AddSubTask(binariesConfiguratorStep); } if (_projectInfo.IsRemote == false) { // Run powershell script var runPowerShellScriptStep = new RunPowerShellScriptStep( _projectInfo.IsRemote, null, new Lazy<string>(() => extractArtifactsDeploymentStep.BinariesDirPath), _projectInfo.ScriptName); AddSubTask(runPowerShellScriptStep); return; } foreach (var targetMachineName in targetMachineNames) { // Create temp dir on remote machine var createRemoteTempDirStep = new CreateRemoteTempDirStep(targetMachineName); AddSubTask(createRemoteTempDirStep); // Copy files to remote machine string machineName = targetMachineName; var copyFilesDeploymentStep = new CopyFilesDeploymentStep( _directoryAdapter, srcDirPathProvider : new Lazy<string>(() => extractArtifactsDeploymentStep.BinariesDirPath), dstDirPath: new Lazy<string>(() => EnvironmentInfo.GetNetworkPath(machineName, createRemoteTempDirStep.RemoteTempDirPath))); AddSubTask(copyFilesDeploymentStep); // Run powershell script var runPowerShellScriptStep = new RunPowerShellScriptStep( _projectInfo.IsRemote, targetMachineName, new Lazy<string>(() => createRemoteTempDirStep.RemoteTempDirPath), _projectInfo.ScriptName); AddSubTask(runPowerShellScriptStep); // Delete remote temp dir var removeRemoteDirectory = new RemoveRemoteDirectoryStep( targetMachineName, new Lazy<string>(() => createRemoteTempDirStep.RemoteTempDirPath)); AddSubTask(removeRemoteDirectory); } }
protected override void DoPrepare() { EnvironmentInfo environmentInfo = GetEnvironmentInfo(); TerminalAppProjectInfo projectInfo = GetProjectInfo<TerminalAppProjectInfo>(); // 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, _directoryAdapter, _zipFileAdapter); AddSubTask(extractArtifactsDeploymentStep); if (projectInfo.ArtifactsAreEnvironmentSpecific) { var binariesConfiguratorStep = new ConfigureBinariesStep( environmentInfo.ConfigurationTemplateName, GetTempDirPath()); AddSubTask(binariesConfiguratorStep); } var extractVersionDeploymentStep = new ExtractVersionDeploymentStep( new Lazy<string>(() => extractArtifactsDeploymentStep.BinariesDirPath), projectInfo.TerminalAppExeName ); AddSubTask(extractVersionDeploymentStep); var prepareVersionedFolderDeploymentStep = new PrepareVersionedFolderDeploymentStep( DeploymentInfo.ProjectName, environmentInfo.GetTerminalServerNetworkPath(environmentInfo.TerminalAppsBaseDirPath), projectInfo.TerminalAppDirName, new Lazy<string>(() => extractVersionDeploymentStep.Version)); AddSubTask(prepareVersionedFolderDeploymentStep); AddSubTask( new CleanDirectoryDeploymentStep( _directoryAdapter, _fileAdapter, new Lazy<string>(() => prepareVersionedFolderDeploymentStep.VersionDeploymentDirPath), excludedDirs: new string[] { })); AddSubTask( new CopyFilesDeploymentStep( _directoryAdapter, new Lazy<string>(() => extractArtifactsDeploymentStep.BinariesDirPath), new Lazy<string>(() => prepareVersionedFolderDeploymentStep.VersionDeploymentDirPath))); AddSubTask( new UpdateApplicationShortcutDeploymentStep( environmentInfo.GetTerminalServerNetworkPath(environmentInfo.TerminalAppsShortcutFolder), new Lazy<string>(() => prepareVersionedFolderDeploymentStep.VersionDeploymentDirPath), projectInfo.TerminalAppExeName, projectInfo.Name)); }
protected override void DoPrepare() { EnvironmentInfo environmentInfo = GetEnvironmentInfo(); var projectInfo = GetProjectInfo<ProjectInfo>(); // 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, _directoryAdapter, _zipFileAdapter); AddSubTask(extractArtifactsDeploymentStep); if (projectInfo.ArtifactsAreEnvironmentSpecific) { var binariesConfiguratorStep = new ConfigureBinariesStep( environmentInfo.ConfigurationTemplateName, GetTempDirPath()); AddSubTask(binariesConfiguratorStep); } AddSubTask( new CopyFilesDeploymentStep( _directoryAdapter, new Lazy<string>(() => extractArtifactsDeploymentStep.BinariesDirPath), new Lazy<string>(() => PreparePackageDirPath(PackageDirPath)))); }
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, _directoryAdapter, _zipFileAdapter); AddSubTask(extractArtifactsDeploymentStep); if (projectInfo.ArtifactsAreEnvironmentSpecific) { var binariesConfiguratorStep = new ConfigureBinariesStep( environmentInfo.ConfigurationTemplateName, GetTempDirPath()); AddSubTask(binariesConfiguratorStep); } WebAppProjectConfiguration configuration = environmentInfo.GetWebAppProjectConfiguration(projectInfo); CheckConfiguration(configuration); 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 (_applicationConfiguration.CheckIfAppPoolExists && !_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); } } }