Deployment 如何在ProjectName.deploy.cmd中传递sitename

Deployment 如何在ProjectName.deploy.cmd中传递sitename,deployment,msbuild,msdeploy,Deployment,Msbuild,Msdeploy,我正在尝试运行MSBuild在传递参数/p:DeployOnBuild=True时生成的ProjectName.deply.cmd。其中一个参数“ComputerName”将作为https://WebServer01:8172/MSDeploy.axd?SiteName=MySiteName。我的命令行是 ProjectName.deploy.cmd /Y /M:https://WebServer01:8172/MSDeploy.axd?Site=MySiteName

我正在尝试运行MSBuild在传递参数
/p:DeployOnBuild=True
时生成的ProjectName.deply.cmd。其中一个参数“ComputerName”将作为
https://WebServer01:8172/MSDeploy.axd?SiteName=MySiteName
。我的命令行是

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

Error: Unrecognized argument 'MySiteName'. All arguments must begin with "-".
实际执行的命令是

"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
请注意/M
https://WebServer01:8172/MSDeploy.axd?Site=MySiteName
被分为两个参数,从而创建
computerName=https://WebServer01:8172/MSDeploy.axd?Site“
和额外参数
MySiteName

我已经讲过了,但这只涉及
ArgMsDeployAdditionalFlags
,而不涉及参数,例如
/M:ComputerName

如果未传递SiteName,我可以使用在服务器上具有管理员权限的用户来完成部署,但是如果使用标准IIS用户DeployUserName,我会得到401

ProjectName.deploy.cmd /Y /M:https://WebServer01:8172/MSDeploy.axd
                       -AllowUntrusted /U:DeployUserName /P:Password /A:Basic
服务器返回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.

该用户的权限很好,因为使用该用户的
VS2012
MSDeploy
配置文件发布工作正常。我还可以生成
msdeploy.exe
命令,并且运行良好。我必须使用
ProjectName.deploy.cmd
,因为它是作为
Team Build
的一部分从
TFS2010

生成的,您试过引用这个参数吗

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

我想我会为任何像我这样的人添加答案,他们会偶然发现这个问题,试图找出为什么这个问题不起作用,谁会想要等效的msdeploy命令

如注释中所述,由于MS文档中参数的解析方式存在缺陷,引用参数将不起作用:

在撰写本文时,由于Web发布管道中的错误 (WPP),无法使用端点地址运行.deploy.cmd文件 它包括一个查询字符串。在此场景中,您需要部署 通过直接使用MSDeploy.exe创建web包

资料来源:

因此,您应该直接使用MSDeploy。与问题中的deploy.cmd参数等效:

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
MSDeploy.exe-源代码:package='\.zip'
-dest:auto,computerName=“https://:8172/MSDeploy.axd”,userName=“”,password=“”,authtype=“Basic”,includeAcls=“False”
-动词:sync
-disableLink:AppPoolExtension
-disableLink:ContentExtension
-disableLink:CertificateExtension
-setParamFile:“\.SetParameters.xml”
-setParam:name=“IIS Web应用程序名称”,value=“”
-AllowUntrusted

(替换方括号内的单词)

这是问题中的一个打字错误。我已经修好了。问题不在于争论本身。这是命令提示符处理=的方式,然后在deploy.cmd脚本中进行安排,以进一步传递给msdeploy.exe。我确信我尝试过将此方法与其他变体一起转义=,但那天它们都不起作用:(今天我从这个开始,第一次尝试就成功了。虽然没有其他与安全相关的问题,但这些都是直截了当的。通过这个工作,我不需要部署用户的管理员权限(这是我想要的)。感谢@Richard的帮助。我需要computerName=“
https://:8172/MSDeploy.axd
?site=”特别是为了模拟VisualStudio部署行为,非常感谢Martin!终于让我的部署成功了。