Is it possible to specify preSync/postSync commands via MSDeploy task? If not, how do I accomplish this?
Asked
Active
Viewed 568 times
1 Answers
1
What kind of MSDeploy task are you using? If it's through Exec of msdeploy.exe then yes, of course, if it's some kind of a wrapper that doesn't support them directly then you can emulate those by calling sync again with run-command provider since pre/post-sync is just another call to sync within try/catch/finally structure wrapping main sync anyway.
private int ExecuteWorker()
{
...
if (!this.HandleAuxillarySync("-preSync", this._commandLine._preSyncParameters, retbaseOptions2))
return -1;
DeploymentChangeSummary deploymentChangeSummary;
try
{
deploymentChangeSummary = @object.SyncTo(retproviderOptions2, retbaseOptions2, syncOptions);
}
...
finally
{
this.HandleAuxillarySync("-postSync", this._commandLine._postSyncParameters, retbaseOptions2);
}
this.HandleAuxillarySync("-postSyncOnSuccess", this._commandLine._postSyncOnSuccessParameters, retbaseOptions2);
...
private bool HandleAuxillarySync(string syncType, Dictionary<string, string> sourceParameters, DeploymentBaseOptions destBaseOptions)
{
...
try
{
using (DeploymentObject @object = DeploymentManager.CreateObject(retproviderOptions, retbaseOptions))
@object.SyncTo(destBaseOptions, syncOptions);
flag = true;
}

Ilya Kozhevnikov
- 10,242
- 4
- 40
- 70
-
I am using MSBuild task MSDeploy from Microsoft.Web.Publishing.targets. – Alex I Jun 06 '12 at 03:39
-
In that case no, just call separate syncs conditionally pre and post your main sync just like the exe itself does. – Ilya Kozhevnikov Jun 06 '12 at 04:29