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 "c:\web1" "\\REMOTEMACHINE\web1" /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?
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With