如何让 TFS2010 通过 MSBUILD 为我运行 MSDEPLOY? [英] How can I get TFS2010 to run MSDEPLOY for me through MSBUILD?

查看:22
本文介绍了如何让 TFS2010 通过 MSBUILD 为我运行 MSDEPLOY?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Vishal Joshi 有一篇精彩的 PDC 演讲可在此处获得,其中描述了新的 MSDEPLOYVisual Studio 2010 中的功能 - 以及如何在 TFS 中部署应用程序.(还有来自 Scott Hanselman 的精彩演讲,但他没有进入 TFS).

There is an excellent PDC talk available here from Vishal Joshi which describes the new MSDEPLOY features in Visual Studio 2010 - as well as how to deploy an application within TFS. (There's also a great talk from Scott Hanselman but he doesn't go into TFS).

您可以在 TFS2010 中使用 MSBUILD 调用 MSDEPLOY 将您的包部署到 IIS.这是通过 MSBUILD 的参数完成的.

You can use MSBUILD within TFS2010 to call through to MSDEPLOY to deploy your package to IIS. This is done by means of parameters to MSBUILD.

讲座解释了一些命令行参数,例如:

The talk explains some of the command line parameters such as :

/p:DeployOnBuild
/p:DeployTarget=MsDeployPublish
/p:CreatePackageOnPublish=True
/p:MSDeployPublishMethod=InProc
/p:MSDeployServiceURL=localhost
/p:DeployIISAppPath="Default Web Site"

但是这方面的文档在哪里 - 我找不到任何文档?

我一整天都在试图让它发挥作用,但无法完全正确并以各种错误告终.如果我运行包的 cmd 文件,它会完美部署.如果我通过 Visual Studio 运行 WebDeploy,它也能完美运行.

I've been spending all day trying to get this to work and can't quite get it right and keep ending up with various errors. If I run the package's cmd file it deploys perfectly. If I run WebDeploy through Visual Studio it also works perfectly.

但我希望使用这些参数通过 msbuild 运行整个部署,而不是单独调用 msdeploy 或运行包 .cmd 文件.我该怎么做?

But I want to get the whole deployment running through msbuild using these arguments and not a separate call to msdeploy or running the package .cmd file. How can I do this?

附注.是的,我确实在运行 Web 部署代理服务.我也有在 IIS 下运行的管理服务.我试过两者都用.

PS. Yes I do have the Web Deployment Agent Service running. I also have the management service running under IIS. I've tried using both.

我正在使用的参数:

/p:DeployOnBuild=True 
/p:DeployTarget=MsDeployPublish 
/p:Configuration=Release 
/p:CreatePackageOnPublish=True  
/p:DeployIisAppPath=staging.example.com   
/p:MsDeployServiceUrl=https://staging.example.com:8172/msdeploy.axd 
/p:AllowUntrustedCertificate=True

给我:

C:Program Files (x86)MSBuildMicrosoftVisualStudiov10.0WebMicrosoft.Web.Publishing.targets (2660):VsMsdeploy 失败.(远程代理(URL https://staging.example.com:8172/msdeploy.axd?site=staging.example.com) 无法联系.请确保在目标计算机上安装并启动了远程代理服务.)错误详细信息:远程代理(URL https://staging.example.com:8172/msdeploy.axd?site=staging.example.com) 不能联系了.确保在目标计算机上安装并启动了远程代理服务.收到了不受支持的响应.响应标头MSDeploy.Response"为",但应为v1".远程服务器返回错误:(401) 未经授权.

C:Program Files (x86)MSBuildMicrosoftVisualStudiov10.0WebMicrosoft.Web.Publishing.targets (2660): VsMsdeploy failed.(Remote agent (URL https://staging.example.com:8172/msdeploy.axd?site=staging.example.com) could not be contacted. Make sure the remote agent service is installed and started on the target computer.) Error detail: Remote agent (URL https://staging.example.com:8172/msdeploy.axd?site=staging.example.com) could not be contacted. Make sure the remote agent service is installed and started on the target computer. An unsupported response was received. The response header 'MSDeploy.Response' was '' but 'v1' was expected. The remote server returned an error: (401) Unauthorized.

推荐答案

IIS7 + 相关解答 ....

好的 - 这就是我最终要做的.或多或少,请关注本主题/问题中 Simon Weaver 的帖子.

但是当涉及到 MSBuild 设置时……这里的大多数人都在使用以下设置:/p:MSDeployPublishMethod=RemoteAgent 这对于 IIS7 来说不正确.使用此设置意味着 TFS 尝试连接到 url:https://your-server-name/MSDEPLOYAGENTSERVICE 但要访问该 url,进行身份验证的用户需要是管理员.这很糟糕.(并且您需要勾选管理员覆盖规则).我认为这个 url 是针对 IIS6 的.

But when it comes to the MSBuild settings .. most people here are using following setting: /p:MSDeployPublishMethod=RemoteAgent which is NOT RIGHT for IIS7. Using this setting means TFS tries to connect to the url: https://your-server-name/MSDEPLOYAGENTSERVICE But to access that url, the user to authenticate needs to be an Admin. Which is fraked. (And you need to have the Admin-override rule thingy ticked). This url is for IIS6 I think.

这是您尝试使用 RemoteAgent 连接时的标准错误消息:-

Here's the standard error message when you try to connect using RemoteAgent :-

C:程序文件(x86)MSBuildMicrosoftVisualStudiov10.0WebMicrosoft.Web.Publishing.targets(3588):Web 部署任务失败.(远程代理(URLhttp://your-web-server/MSDEPLOYAGENTSERVICE)联系不上.确保远程代理服务已安装并在目标计算机上启动.)确定站点名称、用户名和密码正确.如果问题是未解决,请联系您的本地或服务器管理员.错误详细信息:远程代理(URLhttp://your-web-server/MSDEPLOYAGENTSERVICE)联系不上.确保远程代理服务已安装并在目标计算机上启动.一个收到了不支持的回复.这响应头MSDeploy.Response"是V1",但预期为v1".这远程服务器返回错误:(401)未经授权.

C:Program Files (x86)MSBuildMicrosoftVisualStudiov10.0WebMicrosoft.Web.Publishing.targets (3588): Web deployment task failed.(Remote agent (URL http://your-web-server/MSDEPLOYAGENTSERVICE) could not be contacted. Make sure the remote agent service is installed and started on the target computer.) Make sure the site name, user name, and password are correct. If the issue is not resolved, please contact your local or server administrator. Error details: Remote agent (URL http://your-web-server/MSDEPLOYAGENTSERVICE) could not be contacted. Make sure the remote agent service is installed and started on the target computer. An unsupported response was received. The response header 'MSDeploy.Response' was 'V1' but 'v1' was expected. The remote server returned an error: (401) Unauthorized.

所以..你需要把你的MSDeployPublishMethod改成这样:

So .. you need to change your MSDeployPublishMethod to this:

/p:MSDeployPublishMethod=WMSVC

WMSVC 代表 Windows 管理器服务.它基本上是远程代理的更新包装器,但现在允许我们正确提供用户名和密码 .. 用户不必是管理员!(快乐!)所以现在您可以正确设置您想要访问的用户.. 每个网站..

The WMSVC stands for Windows Manager Service. It's basically a newer wrapper over the Remote Agent but now allows us to correct provide a user name and password .. where the user does NOT have to be an admin! (joy!) So now you can correct set which users u want to have access to .. per WebSite ..

它现在也尝试访问 url:https://your-web-server:8172/MsDeploy.axd <-- 这正是 Visual Studio 2010 发布 窗口确实如此!(天哪 -> PENNY DROPS!! BOOM!)

It also now tries to hit the the url: https://your-web-server:8172/MsDeploy.axd <-- which is EXACTLY what the Visual Studio 2010 Publish window does! (OMG -> PENNY DROPS!! BOOM!)

这是我的最终 MSBuild 设置:

And here's my final MSBuild settings:

/p:DeployOnBuild=True
/p:DeployTarget=MSDeployPublish 
/p:MSDeployPublishMethod=WMSVC
/p:MsDeployServiceUrl=your-server-name
/p:DeployIISAppPath=name-of-the-website-in-iis7    
/p:username=AppianMediasome-domain-user 
/p:password=JonSkeet<3<3<3
/p:AllowUntrustedCertificate=True

注意到用户名中有域名了吗?你需要那个,那里.此外,在我的图片中,我已允许我们的域用户访问该网站进行管理.因此,我添加的新用户帐户 (TFSBuildService) 具有 Domain Users 组的成员资格......这就是它的工作原理.

Notice the username has the domain name in it? Ya need that, there. Also, in my picture, I've allowed our DOMAIN USERS access to the website for managament. As such, my new user account i added (TFSBuildService) has Membership to the Domain Users group ... so that's how it all works.

现在 - 如果你已经阅读了所有这些内容,请养一只 lolcat(因为它们是 SOOOOOOOO 2007)......

Now - if u've read all this, have a lolcat (cause they are SOOOOOOOO 2007)....

这篇关于如何让 TFS2010 通过 MSBUILD 为我运行 MSDEPLOY?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆