Get Web Deploy to run a batch file after publish
Asked Answered
N

1

6

I'm using Web Deploy to publish a web application from Visual Studio 2012 to my target IIS server. All fine there!

I now want to deploy to multiple servers in a web farm (within a workgroup). I have produced a Robocopy script to copy the files over the network to the other hosts once it has been deployed to the first web server. I can run this bat file manually no problem but I would like to automate it within the deployment process.

So far I've managed to edit the .pubxml file in my VS project as follows.

  <ItemGroup>
    <MsDeploySourceManifest Include="runCommand">
      <Path>robocopy &quot;c:\web1&quot; &quot;\\REMOTEMACHINE\web1&quot; /MIR</Path>
    </MsDeploySourceManifest>
  </ItemGroup>

This runs the command OK but before all files have been synchronised. Also according to the publish log it's running twice. In the middle of the file sync process.

How can I adapt the .pubxml file to run that command only after all files are synchronised?

Nance answered 11/7, 2014 at 15:23 Comment(0)
N
3

I believe I've resolved this by wrapping the ItemGroup in a Target with AfterTargets set to AddIisSettingAndFileContentsToSourceManifest.

I'm still not sure why the command is being executed twice? And I would welcome any other suggestions on how I can simplify this operation.

  <Target Name="RoboCopyToHosts" AfterTargets="AddIisSettingAndFileContentsToSourceManifest">
    <ItemGroup>
      <MsDeploySourceManifest Include="runCommand">
         ....
         ....
      </MsDeploySourceManifest>
    </ItemGroup>
  </Target>
Nance answered 11/7, 2014 at 15:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.