Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make an HTTP request from MSBuild script

Tags:

msbuild

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

like image 443
Alex Krupnov Avatar asked Mar 17 '11 13:03

Alex Krupnov


2 Answers

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

like image 80
Bas Jansen Avatar answered Nov 15 '22 06:11

Bas Jansen


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>
like image 8
Oliver Avatar answered Nov 15 '22 08:11

Oliver