title: Visual Studio 2010 Web Deploy to Remote Server using MSBuild
body: <p>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.</p>
  
  <p>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:</p>
  
  <p><strong>MSBuild Command:</strong></p>
  
  <p>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</p>
  
  <p><strong>Error:</strong></p>
  
  <p>error : Could not complete the request to remote agent URL 
  'https://http//localhost:8172/MsDeploy.axd?site=Default Web Site'.</p>
  
  <p>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.  </p>
  
  <p>When I specify the URL as https:// the same error still occurs:</p>
  
  <p><strong>Error:</strong></p>
  
  <p>Could not complete the request to remote agent URL 
  'https://localhost:8172/MsDeploy.axd?site=Default Web Site'.</p>
  
  <p>Running the MSBuild command with an MSDeployPublishMethod of InProc works locally however this option does mot allow for deployment remotely.</p>
  
  <p><strong>MSBuild Command:</strong></p>
  
  <p>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></p>
  
  <p>I have also tried using the MSDeployPublishMethod of RemoteAgent but this results in the following error:</p>
  
  <p><strong>Error:</strong></p>
  
  <p>Remote agent (URL <a href="http://localhost/MsDeployAgentService" rel="nofollow">http://localhost/MsDeployAgentService</a>) could not be contacted.<br>
  Make sure the remote agent service is installed and started on the target computer.</p>
  
  <p>The MSBuild command is as follows:</p>
  
  <p><strong>MSBuild Command:</strong></p>
  
  <p>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></p>
  
  <p>What am I missing?</p>