DeploymentWellKnownProvider Enumeration
Defines the list of known deployment provider factories.
Assembly: Microsoft.Web.Deployment (in Microsoft.Web.Deployment.dll)
The following example uses the enumeration DeploymentWellKnownProvider to implement a sync operation with the method SyncTo. DeploymentWellKnownProvider is a safer method of using shipped providers compared to manually inputted strings, which is an offered overload of CreateObject.
Note: |
|---|
The switch statement helps to demonstrate the various elements in the enumeration |
using System;
using Microsoft.Web.Deployment;
namespace MSDeploy.Web.Deployment
{
class Program
{
public enum OSVersion
{
Windows2003,
Windows2008,
}
public enum SyncTypes
{
Content,
File,
Server
}
static void Main(string[] args)
{
string _path = args[0];
OSVersion _osVersion = OSVersion.Windows2003;
SyncTypes _syncType = SyncTypes.Server;
DeploymentWellKnownProvider _provider =
DeploymentWellKnownProvider.Unknown;
switch (_syncType)
{
case SyncTypes.Content:
_provider =
DeploymentWellKnownProvider.ContentPath;
break;
case SyncTypes.File:
_provider = DeploymentWellKnownProvider.FilePath;
break;
case SyncTypes.Server:
if (_osVersion == OSVersion.Windows2003)
{
_provider = DeploymentWellKnownProvider.WebServer60;
}
else if (_osVersion == OSVersion.Windows2008)
{
_provider = DeploymentWellKnownProvider.AppHostConfig;
}
break;
default:
throw new NotImplementedException();
}
DeploymentSyncOptions syncOptions =
new DeploymentSyncOptions();
DeploymentBaseOptions sourceBaseOptions =
new DeploymentBaseOptions();
DeploymentBaseOptions destinationBaseOptions =
new DeploymentBaseOptions();
DeploymentObject deploymentObject =
DeploymentManager.CreateObject(
provider, path, sourceBaseOptions);
deploymentObject.SyncTo(
provider,_path, destinationBaseOptions, syncOptions);
}
}
}
Note: