Make an HTTP request from MSBuild script

主宰稳场 提交于 2019-12-19 06:17:14

问题


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


回答1:


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




回答2:


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>


来源:https://stackoverflow.com/questions/5339632/make-an-http-request-from-msbuild-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!