7

我正在尝试运行参数/p:DeployOnBuild=True传递时由 MSBuild 生成的 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'and 和额外的参数MySiteName

我已经完成了在 Visual Studio 2010 Service Pack 1 中运行带引号参数的部署包失败,但这仅处理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.

该用户的权限很好,因为使用该用户VS2012MSDeploy配置文件发布工作正常。我也可以构建msdeploy.exe命令,并且运行良好。我必须使用ProjectName.deploy.cmd它作为Team Buildfrom的一部分生产的TFS2010

4

2 回答 2

9

您是否尝试过引用该论点?

ProjectName.deploy.cmd /Y "/M:https://WebServer01:8172/MSDeploy.axd?Site=MySiteName" 
                   -AllowUntrusted /U:DeployUserName /P:Password /A:Basic
于 2012-10-04T11:43:11.370 回答
3

以为我会为像我这样偶然发现此问题的其他人添加答案,试图弄清楚为什么这不起作用,以及谁想要等效的 msdeploy 命令。

正如评论中提到的那样,由于参数解析方式存在错误,引用该参数将不起作用,来自 MS 文档:

在撰写本文时,由于 Web 发布管道 (WPP) 中的错误,您无法使用包含查询字符串的端点地址运行 .deploy.cmd 文件。在这种情况下,您需要直接使用 MSDeploy.exe 部署您的 Web 包。

来源:https ://docs.microsoft.com/en-us/aspnet/web-forms/overview/deployment/web-deployment-in-the-enterprise/deploying-web-packages

因此,您应该直接使用 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

(替换带尖括号的单词)

于 2018-03-26T13:07:01.953 回答