How can I get TFS2010 to run MSDEPLOY for me through MSBUILD?

IIS7 + related answer ….

Ok – here’s what I ended up doing. More or less, following the post by Simon Weaver in this thread/question.

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.

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

Standard 401 Frak Off u suck RemoteAgent, error

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.

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

/p:MSDeployPublishMethod=WMSVC

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 ..

enter image description here

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!)

enter image description here

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=AppianMedia\some-domain-user 
/p:password=JonSkeet<3<3<3
/p:AllowUntrustedCertificate=True

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.

Now – if u’ve read all this, have a lolcat (cause they are SOOOOOOOO 2007)….

enter image description here

Leave a Comment