title: How to pass the sitename in ProjectName.deploy.cmd
body: <p>I am trying to run the ProjectName.deply.cmd that is generated by MSBuild when the paramter <code>/p:DeployOnBuild=True</code> is passed. One of the argument "ComputerName" is to be passed as <code>https://WebServer01:8172/MSDeploy.axd?SiteName=MySiteName</code>. My command line would be</p>
  
  <pre><code>ProjectName.deploy.cmd /Y /M:https://WebServer01:8172/MSDeploy.axd?Site=MySiteName 
                         -AllowUntrusted /U:DeployUserName /P:Password /A:Basic
  </code></pre>
  
  <p>It returns</p>
  
  <pre><code>Error: Unrecognized argument 'MySiteName'. All arguments must begin with "-".
  </code></pre>
  
  <p>the actual command that is executed is</p>
  
  <pre><code>"C:\Program Files\IIS\Microsoft Web Deploy V3\\msdeploy.exe" 
      -source:package='Y:\ProjectName.zip'
      -dest:auto,computerName='https://WebServer01:8172/MSDeploy.axd?Site',userName='DeployUserName',password='Password',authtype='Basic',includeAcls='False'
      -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension 
      -disableLink:CertificateExtension 
      -setParamFile:"Y:\ProjectName.SetParameters.xml"
      MySiteName
      -AllowUntrusted
  </code></pre>
  
  <p>Notice that the argument to /M <code>https://WebServer01:8172/MSDeploy.axd?Site=MySiteName</code> is split into two arguments and thus creating <code>computerName='https://WebServer01:8172/MSDeploy.axd?Site'</code> and and extra argument <code>MySiteName</code>.</p>
  
  <p>I have gone through <a href="http://support.microsoft.com/kb/2537134">Running a deployment package with quoted parameters fails in Visual Studio 2010 Service Pack 1</a> but that takes care of only <code>ArgMsDeployAdditionalFlags</code> and not the arguments e.g. <code>/M:ComputerName</code>.</p>
  
  <p>When the SiteName is not passed, I can do the deployment fine with an user that had admin rights on the server but when a standard IIS user DeployUserName is used I get 401</p>
  
  <pre><code>ProjectName.deploy.cmd /Y /M:https://WebServer01:8172/MSDeploy.axd
                         -AllowUntrusted /U:DeployUserName /P:Password /A:Basic
  </code></pre>
  
  <p>The server returns 401</p>
  
  <pre><code>Error Code: ERROR_USER_UNAUTHORIZED
  More Information: Connected to the remote computer ("WebServer01") using the Web 
  Management Service, but could not authorize. Make sure that you are using the
  correct user name and password, that the site you are connecting to exists, and
  that the credentials represent a user who has permissions to access the site.
  Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_UNAUTHORIZED.
  
  Error: The remote server returned an error: (401) Unauthorized.
  </code></pre>
  
  <p>The permissions for that user are fine as the publish from <code>VS2012</code> with <code>MSDeploy</code> profile using that user works just fine. I can also build <code>msdeploy.exe</code> command and that also runs fine. I have to use the <code>ProjectName.deploy.cmd</code> as it is being produced as part of <code>Team Build</code> from <code>TFS2010</code>.</p>