如何使用MSDeploy API从MSDeploy.exe定义-setParamFile参数?
我正在尝试在powerShell中编写以下内容的等效内容:
msdeploy -verb:sync -source:package="c:\MyZip.zip" -dest:auto -setParamFile="c:\StagingParameters.xml"
这是我到目前为止所拥有的:
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Deployment")
$destBaseOptions = new-object Microsoft.Web.Deployment.DeploymentBaseOptions
$syncOptions = new-object Microsoft.Web.Deployment.DeploymentSyncOptions
$deploymentObject = [Microsoft.Web.Deployment.DeploymentManager]::CreateObject("package","C:\MyZip.zip")
#TODO -setParamFile="c:\StagingParameters.xml"
$deploymentObject.SyncTo("auto","",$destBaseOptions,$syncOptions);
答案 0 :(得分:8)
得爱反射器!
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Deployment")
$destBaseOptions = new-object Microsoft.Web.Deployment.DeploymentBaseOptions
$syncOptions = new-object Microsoft.Web.Deployment.DeploymentSyncOptions
$deploymentObject = [Microsoft.Web.Deployment.DeploymentManager]::CreateObject("package","C:\MyZip.zip")
#-setParamFile
$deploymentObject.SyncParameters.Load("c:\StagingParameters.xml");
$deploymentObject.SyncTo("auto","",$destBaseOptions,$syncOptions);