public TaskResult RunTask(DeploymentContext deploymentContext) { if (Directory.Exists(deploymentContext.OutputDirectory) == false) { Directory.CreateDirectory(deploymentContext.OutputDirectory); } DeploymentArtifact deployPackageFolder = deploymentContext.DeploymentArtifacts.GetArtifactByKey("DeployPackageFolder"); string contentDir = deployPackageFolder != null ? deployPackageFolder.Path : deploymentContext.WebSiteDirectory; string packagePath = Path.Combine(deploymentContext.OutputDirectory, deploymentContext.Name + ".zip"); StringBuilder argumentsBuilder = new StringBuilder(); argumentsBuilder.Append("-verb:sync "); argumentsBuilder.AppendFormat("-source:contentPath='{0}' ", contentDir); argumentsBuilder.AppendFormat("-dest:package='{0}' ", packagePath); var msDeployHelper = new MsDeployRunner(deploymentContext.CurrentLogger); bool success = msDeployHelper.Run(argumentsBuilder.ToString()); if (!success) { return(TaskResult.CreateTotalFailureResult("msdeploy (package) did not complete successfully")); } deploymentContext.DeploymentArtifacts.AddArtifact("DeployPackage", packagePath); return(TaskResult.CreateSuccessfulResult()); }
public TaskResult RunTask(DeploymentContext deploymentContext) { DeploymentArtifact packageArtifact = deploymentContext.DeploymentArtifacts.GetArtifactByKey("DeployPackage"); if (packageArtifact == null) { return(TaskResult.CreateErrorResult("Cannot find deployment package artificat")); } // Get task parameters TaskParameterManager taskParams = deploymentContext.TaskParameters; string siteName = taskParams.GetValue <DeployPackage>("siteName"); string server = taskParams.GetValue <DeployPackage>("server"); string username = taskParams.GetValue <DeployPackage>("username"); string password = taskParams.GetValue <DeployPackage>("password"); StringBuilder argumentsBuilder = new StringBuilder(); argumentsBuilder.Append("-verb:sync "); argumentsBuilder.AppendFormat("-source:package='{0}' ", packageArtifact.Path); argumentsBuilder.AppendFormat("-dest:contentPath='{0}',wmsvc='{1}',username='******',password='******' ", siteName, server, username, password); argumentsBuilder.AppendFormat("-allowUntrusted "); argumentsBuilder.AppendFormat("-enableRule:DoNotDeleteRule"); MsDeployRunner deployRunner = new MsDeployRunner(deploymentContext.CurrentLogger); bool success = deployRunner.Run(argumentsBuilder.ToString()); if (!success) { return(TaskResult.CreateTotalFailureResult("msdeploy (deploy) did not complete successfully.")); } return(TaskResult.CreateSuccessfulResult()); }
protected override void RunTool() { var tool = new MsDeployRunner(FileSystem, Environment, ProcessRunner, Tools); tool.Run(Settings); }