原文地址:that Web Deployment “migrate” operation is “sync” operation with all migration rules enabled

从IIS6 迁移一个应用或整个服务器到 IIS7,需要使用“msdeploy”命令行工具来完成迁移(migrate)。
例如,你可以在服务器上建一个“migration”的包,如下:
msdeploy -verb:sync -source:webserver60 -dest:package=c:\migratedServer.zip
迁移意味着移动更多组件,然后进行同步。有关使用 Web Deployment Tool 进行部署迁移请参阅:
Migrate from IIS 6.0 to IIS 7.0

同样的在C#里可以使用web部署的公用的APIs,你可以写C#进行同步(sync),只是需要启用所有的迁移规则。c#示例代码如下:
http://www.watch-life.net/visual-studio/web-deployment-migrate-operation.html


using System;
using Microsoft.Web.Deployment;
static class Program
{
static void Main()
{
DeploymentWellKnownProvider sourceProvider = DeploymentWellKnownProvider.WebServer60;
string sourcePath = "";     // no path needed for webserver providers
DeploymentBaseOptions sourceBaseOptions = new DeploymentBaseOptions();
/*
         * set base options for source object (webserver)
         */
DeploymentWellKnownProvider destinationProvider = DeploymentWellKnownProvider.Package;
string destinationPath = @"c:\migratedServer.zip";
DeploymentBaseOptions destinationBaseOptions = new DeploymentBaseOptions();
DeploymentSyncOptions destinationSyncOptions = new DeploymentSyncOptions();
// add all migration rules to sync options
DeploymentRuleCollection availableRules = DeploymentSyncOptions.GetAvailableRules();
foreach (DeploymentRule rule in availableRules)
{
if (rule.Name.Equals("MigrateGeneral") ||
rule.Name.Equals("MigrateDependencyCheck") ||
rule.Name.Equals("MigrateAnonymousUser"))
{
destinationSyncOptions.Rules.Add(rule);
}
}
/*
         * set other base and sync options for destination object (package)
         */
using (DeploymentObject deploymentObject = DeploymentManager.CreateObject
(
sourceProvider,
sourcePath,
sourceBaseOptions
))
{
deploymentObject.SyncTo
(
destinationProvider,
destinationPath,
destinationBaseOptions,
destinationSyncOptions
);
}
}
}

 

Web Deployment Tool 下载地址:
Web Deployment Tool 1.0 RC x86
Web Deployment Tool 1.0 RC x64

或者通过Web Platform Installer 下载

 

更多文章见:守望轩[http://www.watch-life.net/]

相关文章:

  • 2018-05-28
  • 2019-07-24
  • 2018-03-06
  • 2018-03-08
  • 2018-11-10
  • 2019-02-13
  • 2020-04-29
  • 2021-11-18
猜你喜欢
  • 2020-03-26
  • 2019-06-19
  • 2019-09-18
  • 2020-07-12
  • 2017-11-30
  • 2021-12-10
  • 2021-12-16
  • 2019-12-06
相关资源
相似解决方案