public void BinariesDirPath_returns_path_with_config_template_name_when_artifacts_are_env_specific()
        {
            // arrange
              var environmentInfo = DeploymentDataGenerator.GetEnvironmentInfo();
              var projectInfo = DeploymentDataGenerator.GetDbProjectInfo(false);

              _deploymentStep =
            new ExtractArtifactsDeploymentStep(
              environmentInfo,
              projectInfo,
              _ProjectConfigurationName,
              _ProjectConfigurationBuildId,
              _ArtifactsFilePath,
              _TargetArtifactsDirPath);

              // act, assert
              Assert.IsTrue(_deploymentStep.BinariesDirPath.Contains(environmentInfo.ConfigurationTemplateName));
        }
        public void BinariesDirPath_returns_path_without_config_template_name_when_artifacts_are_not_env_specific()
        {
            // arrange
              NtServiceProjectInfo projectInfo =
            ProjectInfoGenerator.GetNtServiceProjectInfo(areEnvironmentSpecific: false);

              _deploymentStep =
            new ExtractArtifactsDeploymentStep(
              projectInfo,
              _environmentInfo,
              _deploymentInfo,
              _ArtifactsFilePath,
              _TargetArtifactsDirPath,
              _fileAdapterFake.Object,
              _zipFileAdapterFake.Object);

              _deploymentStep.Prepare();

              // act, assert
              Assert.IsFalse(_deploymentStep.BinariesDirPath.Contains(_environmentInfo.ConfigurationTemplateName));
        }
        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();

              // 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);
              }

              // create a step for copying the binaries to the target machine
              string targetDirPath = Path.Combine(environmentInfo.SchedulerAppsBaseDirPath, _projectInfo.SchedulerAppDirName);

              // create a backup step if needed
              string targetDirNetworkPath = environmentInfo.GetAppServerNetworkPath(targetDirPath);

              if (Directory.Exists(targetDirNetworkPath))
              {
            AddSubTask(new BackupFilesDeploymentStep(targetDirNetworkPath));
              }

              AddSubTask(
            new CopyFilesDeploymentStep(
              extractArtifactsDeploymentStep.BinariesDirPath,
              environmentInfo.GetAppServerNetworkPath(targetDirPath)));

              // determine if the task should be scheduled anew or if its schedule should be updated
              string machineName = environmentInfo.AppServerMachineName;
              string taskName = _projectInfo.SchedulerAppName;
              string executablePath = Path.Combine(targetDirPath, _projectInfo.SchedulerAppExeName);
              bool taskIsScheduled = _taskScheduler.IsTaskScheduled(machineName, taskName);

              // collect password
              EnvironmentUser environmentUser;

              string environmentUserPassword =
            PasswordCollectorHelper.CollectPasssword(
              _passwordCollector,
              environmentInfo,
              environmentInfo.AppServerMachineName,
              _projectInfo.SchedulerAppUserId,
              out environmentUser);

              if (!taskIsScheduled)
              {
            // create a step for scheduling a new app
            AddSubTask(
              new ScheduleNewAppDeploymentStep(
            _taskScheduler,
            machineName,
            _projectInfo,
            executablePath,
            environmentUser.UserName,
            environmentUserPassword));
              }
              else
              {
            // create a step for updating an existing scheduler app
            AddSubTask(
              new UpdateAppScheduleDeploymentStep(
            _taskScheduler,
            machineName,
            _projectInfo,
            executablePath,
            environmentUser.UserName,
            environmentUserPassword));
              }
        }
        protected override void DoPrepare()
        {
            EnvironmentInfo environmentInfo = GetEnvironmentInfo();
              DbProjectInfo projectInfo = GetProjectInfo<DbProjectInfo>();

              DbProjectConfiguration dbProjectConfiguration =
            environmentInfo.GetDbProjectConfiguration(projectInfo.Name);

              DatabaseServer databaseServer =
            environmentInfo.GetDatabaseServer(dbProjectConfiguration.DatabaseServerId);

              string databaseServerMachineName = databaseServer.MachineName;

              // 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);

              // create a step for gathering scripts to run
              var gatherDbScriptsToRunDeploymentStep =
            new GatherDbScriptsToRunDeploymentStep(
              projectInfo.DbName,
              new Lazy<string>(() => extractArtifactsDeploymentStep.BinariesDirPath),
              databaseServerMachineName,
              environmentInfo.Name,
              _dbVersionProvider);

              AddSubTask(gatherDbScriptsToRunDeploymentStep);

              // create a step for running scripts
              var runDbScriptsDeploymentStep =
            new RunDbScriptsDeploymentStep(
              GetScriptRunner(databaseServerMachineName),
              databaseServerMachineName,
              new DeferredEnumerable<DbScriptToRun>(() => gatherDbScriptsToRunDeploymentStep.ScriptsToRun));

              AddSubTask(runDbScriptsDeploymentStep);
        }
        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);

              // create a step for gathering scripts to run
              var gatherDbScriptsToRunDeploymentStep =
            new GatherDbScriptsToRunDeploymentStep(
              extractArtifactsDeploymentStep.BinariesDirPath,
              _projectInfo.DbName,
              environmentInfo.DatabaseServerMachineName,
              environmentInfo.Name,
              _dbVersionProvider);

              AddSubTask(gatherDbScriptsToRunDeploymentStep);

              // create a step for running scripts
              var runDbScriptsDeploymentStep =
            new RunDbScriptsDeploymentStep(
              GetScriptRunner(environmentInfo.DatabaseServerMachineName),
              environmentInfo.DatabaseServerMachineName,
              new DeferredEnumerable<string>(() => gatherDbScriptsToRunDeploymentStep.ScriptsToRun));

              AddSubTask(runDbScriptsDeploymentStep);
        }
        private Lazy<string> AddStepsToObtainBinaries(EnvironmentInfo 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,
              _zipFileAdapter);

              AddSubTask(extractArtifactsDeploymentStep);

              if (_projectInfo.ArtifactsAreEnvironmentSpecific)
              {
            var binariesConfiguratorStep =
              new ConfigureBinariesStep(
            environmentInfo.ConfigurationTemplateName,
            GetTempDirPath());

            AddSubTask(binariesConfiguratorStep);
              }

              return new Lazy<string>(() => extractArtifactsDeploymentStep.BinariesDirPath);
        }
        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);
              }

              bool deployToClusteredEnvironment = environmentInfo.EnableFailoverClusteringForNtServices;

              if (deployToClusteredEnvironment)
              {
            if (string.IsNullOrEmpty(environmentInfo.GetFailoverClusterGroupNameForProject(ProjectName)))
            {
              PostDiagnosticMessage(string.Format("Failover clustering for NT services is enabled for environment '{0}' but there is no cluster group mapping for project '{1}'.", environmentInfo.Name, ProjectName), DiagnosticMessageType.Warn);

              deployToClusteredEnvironment = false;
            }
              }

              if (deployToClusteredEnvironment)
              {
            DoPrepareDeploymentToClusteredEnvironment(
              environmentInfo,
              extractArtifactsDeploymentStep.BinariesDirPath);
              }
              else
              {
            DoPrepareDeploymentToStandardEnvironment(
              environmentInfo,
              extractArtifactsDeploymentStep.BinariesDirPath);
              }
        }
        public void SetUp()
        {
            _environmentInfo = DeploymentDataGenerator.GetEnvironmentInfo();
              _projectInfo = DeploymentDataGenerator.GetDbProjectInfo();

              _deploymentStep = new ExtractArtifactsDeploymentStep(
            _environmentInfo,
            _projectInfo,
            _ProjectConfigurationName,
            _ProjectConfigurationBuildId,
            _ArtifactsFilePath,
            _TargetArtifactsDirPath);
        }
        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,
              _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();
              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);
              }
        }
        public void SetUp()
        {
            _environmentInfo = DeploymentDataGenerator.GetEnvironmentInfo();
              _deploymentInfo = DeploymentInfoGenerator.GetDbDeploymentInfo();
              _projectInfo = ProjectInfoGenerator.GetTerminalAppProjectInfo();
              _fileAdapterFake = new Mock<IFileAdapter>(MockBehavior.Loose);
              _zipFileAdapterFake = new Mock<IZipFileAdapter>(MockBehavior.Loose);

              _deploymentStep =
            new ExtractArtifactsDeploymentStep(
              _projectInfo,
              _environmentInfo,
              _deploymentInfo,
              _ArtifactsFilePath,
              _TargetArtifactsDirPath,
              _fileAdapterFake.Object,
              _zipFileAdapterFake.Object);
        }
        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);
              }

              // copy binaries to the target machine
              string targetDirNetworkPath =
            environmentInfo.GetTerminalServerNetworkPath(
              Path.Combine(environmentInfo.TerminalAppsBaseDirPath, _projectInfo.TerminalAppDirName));

              // create a backup step if needed
              if (Directory.Exists(targetDirNetworkPath))
              {
            AddSubTask(new BackupFilesDeploymentStep(targetDirNetworkPath));
              }

              AddSubTask(
            new CopyFilesDeploymentStep(
              extractArtifactsDeploymentStep.BinariesDirPath,
              targetDirNetworkPath));
        }
        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,
              _zipFileAdapter);

              AddSubTask(extractArtifactsDeploymentStep);

              if (projectInfo.ArtifactsAreEnvironmentSpecific)
              {
            var binariesConfiguratorStep =
              new ConfigureBinariesStep(
            environmentInfo.ConfigurationTemplateName,
            GetTempDirPath());

            AddSubTask(binariesConfiguratorStep);
              }

              AddSubTask(
            new CopyFilesDeploymentStep(
              _directoryAdapter,
              _fileAdapter,
              new Lazy<string>(() => extractArtifactsDeploymentStep.BinariesDirPath),
              new Lazy<string>(() => PreparePackageDirPath(PackageDirPath))));
        }
        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,
              _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 CopyFilesDeploymentStep(
              _directoryAdapter,
              _fileAdapter,
              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));
        }