Get Web Deploy to run a batch file after publishing

I am using Web Deploy to publish a web application from Visual Studio 2012 to my target IIS server. Everything is fine!

Now I want to deploy to multiple servers in a web farm (within a workgroup). I created a Robocopy script to copy files over a network to other hosts as soon as it was deployed to the first web server. I can run this bat file manually without problems, but I would like to automate it during the deployment process.

So far, I have been able to edit the file .pubxmlin my VS project as follows.

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

The OK command is executed, but before all the files have been synchronized. Also, according to the publication journal, it works twice. In the middle of the file synchronization process.

How can I adapt a file .pubxmlto run this command only after synchronizing all the files?

+4
source share
1 answer

I believe that I solved this by wrapping ItemGroupin Targetusing AfterTargetsinstalled on AddIisSettingAndFileContentsToSourceManifest.

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

  <Target Name="RoboCopyToHosts" AfterTargets="AddIisSettingAndFileContentsToSourceManifest">
    <ItemGroup>
      <MsDeploySourceManifest Include="runCommand">
         ....
         ....
      </MsDeploySourceManifest>
    </ItemGroup>
  </Target>
+3
source

Source: https://habr.com/ru/post/1548084/


All Articles