amit_g
amit_g

Reputation: 31260

How to pass the sitename in ProjectName.deploy.cmd

I am trying to run the ProjectName.deply.cmd that is generated by MSBuild when the paramter /p:DeployOnBuild=True is passed. One of the argument "ComputerName" is to be passed as https://WebServer01:8172/MSDeploy.axd?SiteName=MySiteName. My command line would be

ProjectName.deploy.cmd /Y /M:https://WebServer01:8172/MSDeploy.axd?Site=MySiteName 
                       -AllowUntrusted /U:DeployUserName /P:Password /A:Basic

It returns

Error: Unrecognized argument 'MySiteName'. All arguments must begin with "-".

the actual command that is executed is

"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

Notice that the argument to /M https://WebServer01:8172/MSDeploy.axd?Site=MySiteName is split into two arguments and thus creating computerName='https://WebServer01:8172/MSDeploy.axd?Site' and and extra argument MySiteName.

I have gone through Running a deployment package with quoted parameters fails in Visual Studio 2010 Service Pack 1 but that takes care of only ArgMsDeployAdditionalFlags and not the arguments e.g. /M:ComputerName.

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

ProjectName.deploy.cmd /Y /M:https://WebServer01:8172/MSDeploy.axd
                       -AllowUntrusted /U:DeployUserName /P:Password /A:Basic

The server returns 401

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.

The permissions for that user are fine as the publish from VS2012 with MSDeploy profile using that user works just fine. I can also build msdeploy.exe command and that also runs fine. I have to use the ProjectName.deploy.cmd as it is being produced as part of Team Build from TFS2010.

Upvotes: 7

Views: 3348

Answers (2)

Martin
Martin

Reputation: 1150

Thought I'd add to the answer for anyone else like me that stumbles upon this trying to figure out why this doesn't work, and who'd like the equivalent msdeploy command.

As mentioned in the comments quoting the argument won't work due to a bug in how the arguments are parsed, from MS docs:

At the time of writing, due to a bug in the Web Publishing Pipeline (WPP), you can't run the .deploy.cmd file using an endpoint address that includes a query string. In this scenario, you need to deploy your web package by using MSDeploy.exe directly.

Source: https://learn.microsoft.com/en-us/aspnet/web-forms/overview/deployment/web-deployment-in-the-enterprise/deploying-web-packages

So, instead, you should use MSDeploy directly. Equivalent to the deploy.cmd arguments in the question:

MSDeploy.exe -source:package='<fullPathToDeployable>\<projectName>.zip' 
-dest:auto,computerName="https://<ipOrDnsName>:8172/MSDeploy.axd",userName="<userName>",password="<pwd>",authtype="Basic",includeAcls="False" 
-verb:sync 
-disableLink:AppPoolExtension 
-disableLink:ContentExtension 
-disableLink:CertificateExtension 
-setParamFile:"<fullPathToDeployable>\<projectName>.SetParameters.xml"  
-setParam:name="IIS Web Application Name",value="<siteName>" 
-AllowUntrusted

(replace angle-bracketed words)

Upvotes: 3

Richard Szalay
Richard Szalay

Reputation: 84754

Have you tried quoting the argument?

ProjectName.deploy.cmd /Y "/M:https://WebServer01:8172/MSDeploy.axd?Site=MySiteName" 
                   -AllowUntrusted /U:DeployUserName /P:Password /A:Basic

Upvotes: 9

Related Questions