Question:
How do I define the -setParamFile parameter from MSDeploy.exe using the MSDeploy API?
I’m trying to write the equivalent of the following in powerShell:
1 2 |
msdeploy -verb:sync -source:package="c:\MyZip.zip" -dest:auto -setParamFile="c:\StagingParameters.xml" |
Here’s what I have so far:
1 2 3 4 5 6 7 8 9 |
[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); |
Answer:
Gotta love reflector!
1 2 3 4 5 6 7 8 9 10 |
[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); |