Next Post >>
<< Previous Post



Posted by Michael Horvath under Technology  on Aug 09 2022

We make use of a script on our server that hosts our websites to encrypt our web.config and perform various other deployment tasks. For some time we have logged into the server to run this script after publishing our websites from Visual Studio. After doing this for a while we had the idea that Visual Studio should be able to execute our script once the website publish task is completed. We were using File System publish to deploy our website. Long story short, we failed to get the script to execute when our publish task completes. It turns out that this is not supported for File System publish.

After getting some rest from our attempts at implementing this, we decided to give it another try. This time we carefully read what we found from Google searches and found that web deploy of website does support execution of a script after publish completes. Here is what we learned: add the following to your .csproj file for the web application in Visual Studio just before the </Project> tag.

<Target Name="MyTarget" AfterTargets="MSDeployPublish">
     <Exec Command="cmd /c c:\Users\mjhorvath\deployall.bat" />
</Target>

The Exec Command may be any command you wish to use. In our case we execute a batch file script that makes a call to Power Shell to execute another script on our server that performs the tasks we need to complete deployment of the website.

We hope this saves you from duplicating our mistakes while developing this solution. Have a blessed day!

Visual Studio Screen Snapshot That Shows Start Of Script After Publish

Tagged --no tags--
share the love!



comments

there are no comments for this post. be the first to post one!


post your comment

name (*) - required
email address (*) - required
site address
your comment (*) - required

(*) - required


Next Post >>
<< Previous Post