public override int Execute() { logger.Log(StartSectionBreaker); logger.Log("Executing MSDEPLOY package deployment:"); //take the zipped package file, if (!CheckZipPackageFileExists()) { return -1; } int result = ExpectedReturnValue; UnZipFileToTempLocation(); var appOffLineFileTempPath = string.Empty; var appOffLineFileFinalPath = string.Empty; //take the site down whilst deploying the files if (ActionComponentGraph.TakeIisDown) { appOffLineFileTempPath = CreateAppOffLineFile(); appOffLineFileFinalPath = Path.Combine(DestinationPath, AppOffLineFileName); result = new MsDeployFileCopyDeploymentTask(CreateFolderCopyActionComponentGraphFrom(ActionComponentGraph, appOffLineFileTempPath, appOffLineFileFinalPath)).Execute(); } string finalPackageLocation = FindPackageFileRootLocation(); logger.Log(string.Format("Copying package from '{0}' to '{1}'", finalPackageLocation, DestinationPath)); //copy stuff to remote server... take whole folder. result = new MsDeployFileCopyDeploymentTask(CreateFolderCopyActionComponentGraphFrom(ActionComponentGraph, finalPackageLocation, DestinationPath)).Execute(); //bring the site back online. if (!string.IsNullOrWhiteSpace(appOffLineFileFinalPath)) { string msdeployPath = FindFirstValidFileFromList(ActionComponentGraph.MsDeployExeLocations, "MSDEPLOY", true); int tempResult = InvokeExe(msdeployPath, MsDeployTaskExtensions.GetMsDeployDeleteFileParams(ActionComponentGraph, appOffLineFileFinalPath)); if (tempResult != 0) result = tempResult; } //perform clean up at the end. RegisterForCleanUpTempLocation(); logger.Log("Finished Deploying package."); logger.Log(EndSectionBreaker); return result; }
public void TestSortingWillArrangeTasksInOrder() { DeploymentTaskCollection collection = new DeploymentTaskCollection(false, false); IisActionComponentGraph componentGraph1 = new IisActionComponentGraph { ActionType = ActionType.AppPoolCreation, DestinationComputerName = "192.168.10.98:8173", PathToConfigFile = "myfile.config", SourceContentPath = @"someSource\files\" }; IisActionComponentGraph componentGraph2 = new IisActionComponentGraph { ActionType = ActionType.AppPoolRemoval, DestinationComputerName = "192.168.10.98:8173", PathToConfigFile = "myfile1.config", SourceContentPath = @"someSource\files\" }; IisActionComponentGraph componentGraph3 = new IisActionComponentGraph { ActionType = ActionType.AppPoolRemoval, DestinationComputerName = "192.168.10.98:8173", PathToConfigFile = "myfile2.config", SourceContentPath = @"someSource\files\" }; FileCopyActionComponentGraph componentGraph4 = new FileCopyActionComponentGraph { ActionType = ActionType.FileDeployment, DestinationComputerName = "192.168.10.98:8173", SourceContentPath = @"someSource\files\" }; var task1 = new MsDeployAppPoolInstallIisDeploymentTask(componentGraph1); var task2 = new MsDeployAppPoolRemovalIisDeploymentTask(componentGraph2); var task3 = new MsDeployAppPoolRemovalIisDeploymentTask(componentGraph3); var task4 = new MsDeployFileCopyDeploymentTask(componentGraph4); Assert.AreEqual(0, collection.Count); collection.Add(task1); collection.Add(task2); collection.Add(task3); collection.Add(task4); Assert.AreEqual(task1, collection[0]); Assert.AreEqual(task2, collection[1]); Assert.AreEqual(task3, collection[2]); Assert.AreEqual(task4, collection[3]); collection.Sort(); Assert.AreEqual(task2, collection[0]); Assert.AreEqual(task3, collection[1]); Assert.AreEqual(task4, collection[2]); Assert.AreEqual(task1, collection[3]); }