【发布时间】:2016-05-18 02:36:51
【问题描述】:
我正在尝试使用 Visual Studio 中的“发布”按钮向“new relic”发布 http 请求。
在我的发布配置文件中,我选择“网络部署”,然后完成我的设置。之后,我将进入我的“.pubxml”文件并在底部添加一个目标:
<Target Name="AfterBuild">
<Exec Command="curl -H "x-api-key:mykey"
-d "deployment[application_id]=appId"
-d "deployment[description]=MSbuild deploy using curl"
-d "deployment[revision]=0"
-d "deployment[changelog]=Deployed using MSBuild"
-d "deployment[user]=User"
-d http://api.newrelic.com/deployments.xml"/>
</Target>
</project>
在 Visual Studio 的错误列表中,我得到以下信息:
Severity Code Description Project File Line Suppression State Error The command
"curl
-H "x-api-key:APPKEY"
-d "deployment[application_id]=APPID"
-d "deployment[description]=MSbuild deploy using curl"
-d "deployment[revision]=1"
-d "deployment[changelog]=Deployed using MSBuild"
-d "deployment[user]=User"
http://api.newrelic.com/deployments.xml"
exited with code 9009
如果我在 curl.exe 中运行 curl 命令,它可以工作(发布成功)但在 msbuild 期间不能。
正如您在上面看到的,所有内容都带有引号,接受 url,(也尝试过)
我试过像这样指定 curl 的路径
"C:\WINDOWS\system32\curl.exe"
但这并不奏效。
我已删除“ItemGroup”,因为我不希望包含 Web 配置(已在 Web 配置上将 buildaction 设置为“none”)
我可以尝试什么?
更新
<Target Name="AfterBuild"> and <Message Text="Test"/>..
这运行成功,但我在构建输出中看不到“测试”文本。
<Target Name="AfterBuild">
<Exec WorkingDirectory="C:\Windows\System32\" Command="curl http://www.google.com"/>
这会返回错误 9009。
证明它在正确的目录中:
【问题讨论】:
-
我收到来自 curl.exe 的 9009 错误 你确定吗?见stackoverflow.com/questions/1351830/…
-
您好,我更新了我的问题。是的,我已经尝试了路径修复。好吧,我不确定 curl.exe。我可以打开 cmd > 输入“curl”并按回车键 > 输入上面的代码。然后一切正常。我猜 msbuild 找不到 curl 认为它在物理路径“C:\Windows\System32\curl.exe”
-
如果从命令中删除换行符会怎样?
-
如果我只运行
和 它会被发布,但构建输出中不会显示消息“test” -
<Exec Command="C:\Windows\System32\curl http://www.google.com"/>是做什么的?