I'm looking for a way to hit a web app/restful service URL from msbuild script to trigger remote procedure. Is there any way how I can do that except calling that external app? Ideally I'm looking for a way to break a build sequence if service returned something else that http 200
I use the MSBuild Community Tasks a lot. They add extra tasks for MSBuilds. In there is a HttpRequest task which, from the look of it, does what you want.
<HttpRequest Url="http://<mydomain.com>/index.php?checkdb=1"
EnsureResponseContains="Database upgrade check completed successfully."
FailOnNon2xxResponse="true" />
Hope this helps
In version 4 of the MSBuild Community Tasks, the HttpRequest
task was replaced by HttpWebRequest with a different syntax:
<MSBuild.ExtensionPack.Web.HttpWebRequest
TaskAction="GetResponse" Url="http://www.freetodev.com">
<Output TaskParameter="Response" ItemName="ResponseDetail"/>
<Output TaskParameter="Status" PropertyName="ResponseStatus"/>
</MSBuild.ExtensionPack.Web.HttpWebRequest>
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