private async Task PublishContentToAllSites( string contentPath, string siteReplicatorPath) { // Publish to all the target sites in parallel var allChanges = await Task.WhenAll(Instance.Repository.Sites.Select(async site => { return(await PublishContentToSingleSite(site)); })); // Trace all the results for (int i = 0; i < allChanges.Length; i++) { DeploymentChangeSummary changeSummary = allChanges[i]; if (changeSummary == null) { continue; } Trace.TraceInformation("Processed sites: {0}", Instance.Repository.Sites.Count()); Trace.TraceInformation("BytesCopied: {0}", changeSummary.BytesCopied); Trace.TraceInformation("Added: {0}", changeSummary.ObjectsAdded); Trace.TraceInformation("Updated: {0}", changeSummary.ObjectsUpdated); Trace.TraceInformation("Deleted: {0}", changeSummary.ObjectsDeleted); Trace.TraceInformation("Errors: {0}", changeSummary.Errors); Trace.TraceInformation("Warnings: {0}", changeSummary.Warnings); Trace.TraceInformation("Total changes: {0}", changeSummary.TotalChanges); } }
static void Main(string[] args) { if (args.Length < 2) { WriteLine(@"Syntax 1: WAWSDeploy.exe c:\SomeFolder MySite.PublishSettings [/p password]"); WriteLine(@"Syntax 2: WAWSDeploy.exe c:\SomeFile.zip MySite.PublishSettings [/p password]"); return; } // parse the command line args var command = Args.Configuration.Configure <DeploymentArgs>().CreateAndBind(args); try { var webDeployHelper = new WebDeployHelper(); WriteLine("Starting deployment..."); DeploymentChangeSummary changeSummary = webDeployHelper.DeployContentToOneSite(command.Folder, command.PublishSettingsFile, command.Password); WriteLine("BytesCopied: {0}", changeSummary.BytesCopied); WriteLine("Added: {0}", changeSummary.ObjectsAdded); WriteLine("Updated: {0}", changeSummary.ObjectsUpdated); WriteLine("Deleted: {0}", changeSummary.ObjectsDeleted); WriteLine("Errors: {0}", changeSummary.Errors); WriteLine("Warnings: {0}", changeSummary.Warnings); WriteLine("Total changes: {0}", changeSummary.TotalChanges); } catch (Exception e) { WriteLine("Deployment failed: {0}", e.Message); } }
public static string ToDisplayValue([NotNull] this DeploymentChangeSummary summary) { if (summary == null) { throw new ArgumentNullException(nameof(summary)); } return(JsonConvert.SerializeObject(summary, Formatting.Indented)); }
internal static void LogObject(this TestEasyLog log, DeploymentChangeSummary changeSummary) { log.Info(string.Format("Deployment Results \n Added: {0}\n Updated: {1}\n Deleted: {2}\n Total Errors: {3}\n Total Changes: {4}", changeSummary.ObjectsAdded, changeSummary.ObjectsUpdated, changeSummary.ObjectsDeleted, changeSummary.Errors, changeSummary.TotalChanges)); }
static void Main(string[] args) { if (args.Length < 2) { WriteLine(@"WAWSDeploy version {0}", typeof(Program).Assembly.GetName().Version); WriteLine(@"Usage: WAWSDeploy.exe c:\SomeFolder MySite.PublishSettings [flags]"); WriteLine(@"Options:"); WriteLine(@" /p /password: provide the password if it's not in the profile"); WriteLine(@" /d /DeleteExistingFiles: delete target files that don't exist at the source"); WriteLine(@" /au /AllowUntrusted: skip cert verification"); WriteLine(@" /v /Verbose: Verbose mode"); WriteLine(@" /w /WhatIf: don't actually perform the publishing"); WriteLine(@" /t /TargetPath: the virtual or physical directory to deploy to"); WriteLine(@" /c /cs: use checksum"); WriteLine(@" /o /AppOffline: automatically take an ASP.Net application offline before publishing to it."); return; } // parse the command line args var command = Args.Configuration.Configure <DeploymentArgs>().CreateAndBind(args); try { var webDeployHelper = new WebDeployHelper(); webDeployHelper.DeploymentTraceEventHandler += Trace; WriteLine("Starting deployment..."); DeploymentChangeSummary changeSummary = webDeployHelper.DeployContentToOneSite( command.Folder, command.PublishSettingsFile, command.Password, command.AllowUntrusted, !command.DeleteExistingFiles, command.TraceLevel, command.WhatIf, command.TargetPath, command.UseChecksum, command.AppOffline ); WriteLine("BytesCopied: {0}", changeSummary.BytesCopied); WriteLine("Added: {0}", changeSummary.ObjectsAdded); WriteLine("Updated: {0}", changeSummary.ObjectsUpdated); WriteLine("Deleted: {0}", changeSummary.ObjectsDeleted); WriteLine("Errors: {0}", changeSummary.Errors); WriteLine("Warnings: {0}", changeSummary.Warnings); WriteLine("Total changes: {0}", changeSummary.TotalChanges); } catch (Exception e) { WriteLine("Deployment failed: {0}", e.Message); Environment.ExitCode = 1; } }
static void Main(string[] args) { var model = Args.Configuration.Configure <DeploymentArgs>(); if (args.Length < 2) { WriteLine(@"WAWSDeploy version {0}", typeof(Program).Assembly.GetName().Version); var help = new HelpProvider(); new ConsoleHelpFormatter().WriteHelp(help.GenerateModelHelp(model), Console.Out); return; } // parse the command line args var command = model.CreateAndBind(args); try { var webDeployHelper = new WebDeployHelper(); webDeployHelper.DeploymentTraceEventHandler += Trace; WriteLine("Starting deployment..."); DeploymentChangeSummary changeSummary = webDeployHelper.DeployContentToOneSite( command.Folder, command.PublishSettingsFile, command.Password, command.AllowUntrusted, !command.DeleteExistingFiles, command.TraceLevel, command.WhatIf, command.TargetPath, command.UseChecksum, command.AppOffline, command.RetryAttempts, command.RetryInterval, command.SkipAppData, command.SkipFoldersRegexps ); WriteLine("BytesCopied: {0}", changeSummary.BytesCopied); WriteLine("Added: {0}", changeSummary.ObjectsAdded); WriteLine("Updated: {0}", changeSummary.ObjectsUpdated); WriteLine("Deleted: {0}", changeSummary.ObjectsDeleted); WriteLine("Errors: {0}", changeSummary.Errors); WriteLine("Warnings: {0}", changeSummary.Warnings); WriteLine("Total changes: {0}", changeSummary.TotalChanges); } catch (Exception e) { WriteLine("Deployment failed: {0}", e.Message); Environment.ExitCode = 1; } }
private async Task PublishContentToAllSites(string contentPath, string publishSettingsPath) { string[] publishSettingsFiles = Directory.GetFiles(publishSettingsPath); Trace.TraceInformation("Publish settings found: {0}", String.Join(",", publishSettingsFiles)); var webDeployHelper = new WebDeployHelper(); // Publish to all the target sites in parallel var allChanges = await Task.WhenAll(publishSettingsFiles.Select(async publishSettingsFile => { try { return(await Task <DeploymentChangeSummary> .Run(() => webDeployHelper.DeployContentToOneSite(Environment.Instance.ContentPath, publishSettingsFile))); } catch (Exception e) { Trace.TraceError("Error processing {0}: {1}", Path.GetFileName(publishSettingsFile), e.ToString()); return(null); } })); // Trace all the results for (int i = 0; i < allChanges.Length; i++) { DeploymentChangeSummary changeSummary = allChanges[i]; if (changeSummary == null) { continue; } Trace.TraceInformation("Processed {0}", Path.GetFileName(publishSettingsFiles[i])); Trace.TraceInformation("BytesCopied: {0}", changeSummary.BytesCopied); Trace.TraceInformation("Added: {0}", changeSummary.ObjectsAdded); Trace.TraceInformation("Updated: {0}", changeSummary.ObjectsUpdated); Trace.TraceInformation("Deleted: {0}", changeSummary.ObjectsDeleted); Trace.TraceInformation("Errors: {0}", changeSummary.Errors); Trace.TraceInformation("Warnings: {0}", changeSummary.Warnings); Trace.TraceInformation("Total changes: {0}", changeSummary.TotalChanges); } }
public void AddSummery(DeploymentChangeSummary summery) { _summeries.Add(summery); }
public DeploymentChangeSummary DeployContentToOneSite( IConfigRepository repository, string contentPath, string publishSettingsFile) { var sourceBaseOptions = new DeploymentBaseOptions(); DeploymentBaseOptions destBaseOptions; string siteName = SetDestBaseOptions(publishSettingsFile, out destBaseOptions); bool success = true; DeploymentChangeSummary summary = null; AddSkips(repository.Config.SkipRules, sourceBaseOptions, destBaseOptions); Trace.TraceInformation("Starting WebDeploy for {0}", Path.GetFileName(publishSettingsFile)); using (StatusFile status = new StatusFile(siteName)) using (LogFile logFile = new LogFile(siteName, false)) { sourceBaseOptions.Trace += logFile.LogEventHandler; destBaseOptions.Trace += logFile.LogEventHandler; try { logFile.Log(TraceLevel.Info, "Beginning sync"); status.State = Models.DeployState.Deploying; status.Save(); // Publish the content to the remote site using (var deploymentObject = DeploymentManager.CreateObject(DeploymentWellKnownProvider.ContentPath, contentPath, sourceBaseOptions)) { // Note: would be nice to have an async flavor of this API... summary = deploymentObject.SyncTo(DeploymentWellKnownProvider.ContentPath, siteName, destBaseOptions, new DeploymentSyncOptions()); } string summaryString = string.Format("Total Changes: {0} ({1} added, {2} deleted, {3} updated, {4} parameters changed, {5} bytes copied)", summary.TotalChanges, summary.ObjectsAdded, summary.ObjectsDeleted, summary.ObjectsUpdated, summary.ParameterChanges, summary.BytesCopied); status.ObjectsAdded = summary.ObjectsAdded; status.ObjectsDeleted = summary.ObjectsDeleted; status.ObjectsUpdated = summary.ObjectsUpdated; status.ParametersChanged = summary.ParameterChanges; status.BytesCopied = summary.BytesCopied; logFile.Log(TraceLevel.Info, summaryString); logFile.Log(TraceLevel.Info, "Sync completed successfully"); } catch (Exception e) { logFile.Log(TraceLevel.Error, e.ToString()); success = false; status.State = Models.DeployState.Failed; } if (success) { status.State = Models.DeployState.Succeeded; } }// Close log file and status file return(summary); }
public ResultAdapter(DeploymentChangeSummary deploymentChangeSummary) =>
public override void ExecuteCmdlet() { PrepareFileFullPaths(); // If a project file is specified, use MSBuild to build the package zip file. if (!string.IsNullOrEmpty(ProjectFile)) { WriteVerbose(string.Format(Resources.StartBuildingProjectTemplate, fullProjectFile)); fullPackage = WebsitesClient.BuildWebProject(fullProjectFile, configuration, Path.Combine(CurrentPath(), "build.log")); WriteVerbose(string.Format(Resources.CompleteBuildingProjectTemplate, fullProjectFile)); } // Resolve the full path of the package file or folder when the "Package" parameter set is used. fullPackage = string.IsNullOrEmpty(fullPackage) ? this.TryResolvePath(Package) : fullPackage; WriteVerbose(string.Format(Resources.StartPublishingProjectTemplate, fullPackage)); fullSetParametersFile = string.IsNullOrEmpty(fullSetParametersFile) ? this.TryResolvePath(SetParametersFile) : fullSetParametersFile; // Convert dynamic parameters to a connection string hash table. var connectionStrings = ConnectionString; if (connectionStrings == null) { connectionStrings = new Hashtable(); if (dynamicParameters != null) { foreach (var dp in dynamicParameters) { if (MyInvocation.BoundParameters.ContainsKey(dp.Key)) { connectionStrings[dp.Value.Name.ToString()] = dp.Value.Value.ToString(); } } } } if (!string.IsNullOrEmpty(fullSetParametersFile) && !File.Exists(fullSetParametersFile)) { if (File.Exists(Path.Combine(Path.GetDirectoryName(fullPackage), fullSetParametersFile))) { WriteVerbose("Setting path for Parameters file to local one to package: " + Path.Combine(Path.GetDirectoryName(fullPackage), fullSetParametersFile)); fullSetParametersFile = Path.Combine(Path.GetDirectoryName(fullPackage), fullSetParametersFile); } } // If tokens are passed in, update the parameters file if there is one if (!string.IsNullOrEmpty(Tokens) && !string.IsNullOrEmpty(fullSetParametersFile)) { // Convert tokens string to hashtable string[] tokenSplit = Tokens.Split(';'); WriteVerbose(string.Format("Replacing tokens in {0}", fullSetParametersFile)); var fileContents = File.ReadAllText(fullSetParametersFile); foreach (string pair in tokenSplit) { string[] data = pair.Split('='); fileContents = fileContents.Replace(string.Format("__{0}__", data[0].Replace("\"", "")), data[1].Replace("\"", "")); } File.WriteAllText(fullSetParametersFile, fileContents); } try { // Publish the package. DeploymentChangeSummary changeSummary = WebsitesClient.PublishWebProject(Name, Slot, fullPackage, fullSetParametersFile, connectionStrings, SkipAppData.IsPresent, DoNotDelete.IsPresent); WriteVerbose(string.Format(Resources.CompletePublishingProjectTemplate, fullPackage)); if (changeSummary != null) { WriteObject("Change Summary:"); WriteObject(string.Format("Bytes Copied: {0}", changeSummary.BytesCopied.ToString())); WriteObject(string.Format("Files Added: {0}", changeSummary.ObjectsAdded.ToString())); WriteObject(string.Format("Files Updated: {0}", changeSummary.ObjectsUpdated.ToString())); WriteObject(string.Format("Files Deleted: {0}", changeSummary.ObjectsDeleted.ToString())); WriteObject(string.Format("Errors: {0}", changeSummary.Errors.ToString())); WriteObject(string.Format("Warnings: {0}", changeSummary.Warnings.ToString())); WriteObject(string.Format("Parameters Changed: {0}", changeSummary.ParameterChanges.ToString())); WriteObject(string.Format("Total No of Changes: {0}", changeSummary.TotalChanges.ToString())); } } catch (Exception) { WriteVerbose(string.Format(Resources.FailPublishingProjectTemplate, fullPackage)); throw; } }