Visual Studio 2010 Web Deploy to Remote Server using MSBuild

iis-7msbuildvisual studio 2010web-deployment

I am running Windows 7 and IIS 7 with Web Deploy 2.0 installed and the 'Web Management Service' and 'Web Deployment Agent Service' both started.

I am trying to use MSBuild to publish the web projects to a remote IIS 7 server but when I run the following MSBuild command that uses a publish method of MSDeployPublishMethod it fails:

MSBuild Command:

MSBuild Projects="[project file]"
Properties="DeployOnBuild=True;
DeployTarget=MsDeployPublish;
CreatePackageOnPublish=True;
MSDeployPublishMethod=WMSVC;
MSDeployServiceUrl=http://localhost:8172/MsDeploy.axd;
DeployIisAppPath=Default Web Site/[my website];
UserName=[username];
Password=[password]">
/MSBuild

Error:

error : Could not complete the request to remote agent URL
'https://http//localhost:8172/MsDeploy.axd?site=Default Web Site'.

The url appears to be prefixed with https and there is no way to specify http although I can specify http through Visual Studio and publish successfully via the IDE.

When I specify the URL as https:// the same error still occurs:

Error:

Could not complete the request to remote agent URL
'https://localhost:8172/MsDeploy.axd?site=Default Web Site'.

Running the MSBuild command with an MSDeployPublishMethod of InProc works locally however this option does mot allow for deployment remotely.

MSBuild Command:

MSBuild Projects="[project file]"
Properties="DeployOnBuild=True;
DeployTarget=MsDeployPublish;
CreatePackageOnPublish=True;
MSDeployPublishMethod=InProc;
MSDeployServiceUrl=localhost;
DeployIisAppPath=Default Web Site/[my website];
UserName=[username];
Password=[password]">
/MSBuild>

I have also tried using the MSDeployPublishMethod of RemoteAgent but this results in the following error:

Error:

Remote agent (URL http://localhost/MsDeployAgentService) could not be contacted.
Make sure the remote agent service is installed and started on the target computer.

The MSBuild command is as follows:

MSBuild Command:

MSBuild Projects="[project file]"
Properties="DeployOnBuild=True;
DeployTarget=MsDeployPublish;
MSDeployPublishMethod=RemoteAgent;
AllowUntrustedCertificated=True;
MSDeployServiceUrl=http://localhost/MsDeployAgentService;
DeployIisAppPath=Default Web Site/[my website];
UserName=[username];
Password=[password]">
/MSBuild>

What am I missing?

Best Answer

For IIS 7, check the following:

MSDeployPublishMethod=WMSVC 

MSDeployServiceUrl=localhost 

AllowUntrustedCertificate=True  -- Unless you have a valid certificate...

MSBuild Projects="[project file]" Properties="DeployOnBuild=True; DeployTarget=MsDeployPublish; CreatePackageOnPublish=True; MSDeployPublishMethod=**WMSVC**; MSDeployServiceUrl=**localhost**; DeployIisAppPath=Default Web Site/[my website]; UserName=[username]; Password=[password]; **AllowUntrustedCertificate=True**"> /MSBuild