Skip to content

Instantly share code, notes, and snippets.

@rodolfofadino
Created July 23, 2013 02:08
Show Gist options
  • Save rodolfofadino/6059331 to your computer and use it in GitHub Desktop.
Save rodolfofadino/6059331 to your computer and use it in GitHub Desktop.
using Microsoft.Web.Deployment;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DemoDeploy
{
class Program
{
static void Main(string[] args)
{
DeploymentBaseOptions opcoesServerOrigem = new DeploymentBaseOptions();
opcoesServerOrigem.Trace += new EventHandler<DeploymentTraceEventArgs>(Source_Trace);
opcoesServerOrigem.TraceLevel = System.Diagnostics.TraceLevel.Verbose;
opcoesServerOrigem.ComputerName = "servidorOrigem"; //pode ser ip ou nome/dns
DeploymentBaseOptions opcoesServerDestino = new DeploymentBaseOptions();
opcoesServerDestino.Trace += new EventHandler<DeploymentTraceEventArgs>(Dest_Trace);
opcoesServerDestino.TraceLevel = System.Diagnostics.TraceLevel.Verbose;
opcoesServerDestino.ComputerName = "servidorDestino"; //pode ser ip ou nome/dns
DeploymentSyncOptions opcoesDeSinc = new DeploymentSyncOptions();
//utilizar em caso de preview das alterações
//opcoesDeSinc.WhatIf = true;
using (DeploymentObject deploy =
DeploymentManager.CreateObject(DeploymentWellKnownProvider.AppHostConfig, "Default Web Site", opcoesServerOrigem))
{
deploy.SyncTo(DeploymentWellKnownProvider.AppHostConfig, "Default Web Site",
opcoesServerDestino, opcoesDeSinc);
}
}
static void Dest_Trace(object sender, DeploymentTraceEventArgs e)
{
string name = System.Reflection.MethodInfo.GetCurrentMethod().Name;
Console.WriteLine(name + ": " + e.Message);
}
static void Source_Trace(object sender, DeploymentTraceEventArgs e)
{
string name = System.Reflection.MethodInfo.GetCurrentMethod().Name;
Console.WriteLine(name + ": " + e.Message);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment