visual-studio-2010 - 如何让 TFS2010 通过 MSBUILD 为我运行 MSDEPLOY?

标签 visual-studio-2010 msbuild msdeploy

有一个很棒的 PDC 演讲 available here来自 Vishal Joshi,其中描述了 Visual Studio 2010 中的新 MSDEPLOY 功能 - 以及如何在 TFS 中部署应用程序。 (Scott Hanselman 也发表了精彩的演讲,但他没有讨论 TFS)。

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

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

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

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

我花了一整天的时间试图让它工作,但无法完全正确,并不断出现各种错误。如果我运行包的 cmd 文件,它就会完美部署。如果我通过 Visual Studio 运行 WebDeploy,它也可以完美运行。

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

PS。是的,我确实运行了Web 部署代理服务。我还在 IIS 下运行管理服务。我尝试过同时使用两者。

<小时/>

我正在使用的参数:

/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)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.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)。确保目标计算机上安装并启动了远程代理服务。收到了不支持的回复。响应 header “MSDeploy.Response”为“”,但预期为“v1”。远程服务器返回错误:(401) 未经授权。

最佳答案

IIS7+相关答案....

好的 - 这就是我最终所做的。或多或少,关注Simon Weaver的帖子在此线程/问题中。

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

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

标准 401 Frak Off u 糟糕的 RemoteAgent,错误

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.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更改为:

/p:MSDeployPublishMethod=WMSVC

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

enter image description here

它现在还尝试访问 URL:https://your-web-server:8172/MsDeploy.axd <-- 这正是 Visual Studio 2010 发布的内容 窗口确实如此! (天哪 -> 便士滴!!繁荣!)

enter image description here

这是我的最终 MSBuild 设置:

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

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

现在 - 如果你读完了所有这些,请养一只哈哈猫(因为它们太 2007 年了)....

enter image description here

关于visual-studio-2010 - 如何让 TFS2010 通过 MSBUILD 为我运行 MSDEPLOY?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2636153/

相关文章:

c# - 编译 XNA 项目时无法执行请求的操作错误

tfs - 我应该在哪里存储团队 build 的共同目标?

msbuild - "AutoParameterizationWebConfigConnectionStrings"-option 是防止连接字符串标记化的唯一方法吗?

c - Visual C++ 2010 Express 代码中的灰色(禁用)文本。这是什么意思?我该如何解决?

visual-studio-2010 - 配置 InstallShield LE 以删除使用 Visual Studio 安装项目构建的先前版本

visual-studio - Visual Studio 链接文件目录结构

c# - Installer工程多次打包文件

msbuild - 禁止 .codeanalysislog.xml 和 .lastcodeanalysisuccceeded 文件被删除

msdeploy - 使用 msdeploy.exe 将文件夹部署到远程站点

.net - msdeploy 忽略 .hgignore