开发者

Web Deploy API (deploy .zip package) Clarification

I'm using the web deploy API to deploy a web package (.zip file, created by MSDeploy.exe) to programmatically roll the package out to a server (we need to do some other things before we release the package which is why we're not doing it all in one go using MSDeploy.exe).

Here's the code I have. My question is really to clarify what is happening when this is executed. In the package parameters XML file I have the application name specified ("开发者_StackOverflow社区Default Web Site") but that's about it, there's no other params are specified in there. From testing the server it appears the package gets deployed successfully but my question is are any other settings on the server I'm deploying to getting changed without my knowledge, are any default settings published etc.? Things like security settings, directory browsing etc. that I might not be aware of? The code here seems to deploy the package but I'm anxious about using this on a production environment when I'm so unsure of how this API works. The MS documentation is not helpful (more like non-existant, actually).

DeploymentChangeSummary changes;

string packageToDeploy = "C:/MyPackageLocation.zip";
string packageParametersFile = "C:/MyPackageLocation.SetParameters.xml";

DeploymentBaseOptions destinationOptions = new DeploymentBaseOptions()
{
    UserName = "MyUsername",
    Password = "MyPassword",
    ComputerName = "localhost"
};

using (DeploymentObject deploymentObject = DeploymentManager.CreateObject(DeploymentWellKnownProvider.Package,
                                                                          packageToDeploy))
{
    deploymentObject.SyncParameters.Load(packageParametersFile);
    DeploymentSyncOptions syncOptions = new DeploymentSyncOptions();
    syncOptions.WhatIf = false;

    //Deploy the package to the server.
    changes = deploymentObject.SyncTo(destinationOptions, syncOptions);
}

If anyone could clarify that this snippet should deploy a package to a web site application on a server, without changing any existing server settings (unless specified in the SetParameters.xml file) that would be really helpful. Any good resources on using the API or an explanation of how web deployment works behind the scenes would also be much appreciated!


The setparameters file just controls the value for the parameters defined in the package. A package might be doing much more than that. Web deploy has a concept of providers and any given package can have one or more providers.

If you want to make sure that the package is not changing server side settings the best approach you can take is to use the API but make the packages be deployed via Web Management Service. This will give you two benefits:

  1. You can control what providers you allow through.
  2. You can add users and give restricted permissions to them to deploy to their site or their folder etc.

The alternate approach is to:

  1. In the package manually look at the archive.xml and look for the providers in the package. As long as you dont see any of the following providers that can cause server settings change such as apphostconfig or webserver or regkey (this is not a comprehensive list) you should be good. Runcommand is a provider that allows you to execute batch scripts or commands. While it is a good provider for admins themselves you need to consider whether you want to allow packages with such providers to run.

  2. You can do the above mentioned inspection in code by calling getchildren on the deployment object you create out of the package and inspect the providers and the provider paths.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜