如何在ProjectName.deploy.cmd中传递网站名称

时间:2012-10-04 07:01:11

标签: deployment msbuild tfs2010 msdeploy

我正在尝试运行由参数/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'和额外参数MySiteName

我已经完成了Running a deployment package with quoted parameters fails in Visual Studio 2010 Service Pack 1,但这只涉及ArgMsDeployAdditionalFlags,而不是例如/M:ComputerNameProjectName.deploy.cmd /Y /M:https://WebServer01:8172/MSDeploy.axd -AllowUntrusted /U:DeployUserName /P:Password /A:Basic

当未传递SiteName时,我可以使用在服务器上具有管理员权限的用户进行部署,但是当使用标准IIS用户DeployUserName时,我得到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.

服务器返回401

VS2012

该用户的权限很好,因为MSDeploy使用msdeploy.exe个人资料发布使用该用户的工作正常。我也可以构建ProjectName.deploy.cmd命令,并且运行正常。我必须使用Team Build,因为它是TFS2010中{{1}}的一部分。

2 个答案:

答案 0 :(得分:9)

您是否尝试引用参数?

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

答案 1 :(得分:0)

以为我会为像我这样的其他任何人添加答案,因为我试图弄清楚为什么这不起作用,以及谁喜欢等效的msdeploy命令。

正如评论中所提到的,由于MS docs中解析参数的方式存在错误,因此该参数将无效:

  

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

来源: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

(替换角括号的单词)