当msbuild使用相同的凭据时,msdeploy 401未经授权的错误

时间:2017-06-06 16:54:37

标签: authentication msbuild continuous-integration msdeploy tfs2017

我正在尝试部署一个网站,最初我有以下命令行

MSBuild.exe PortalWeb.sln
    /t:Rebuild
    /p:DeployOnBuild=True
    /p:DeployTarget=MsDeployPublish
    /p:MSDeployServiceURL=https://wwwt.mycompany.ru:8172/msdeploy.axd
    /p:DeployIISAppPath="Portal/test"
    /p:CreatePackageOnPublish=False
    /p:MsDeployPublishMethod=WMSVC
    /p:AllowUntrustedCertificate=True
    /p:UserName=DeployUser
    /p:Password=123pwd123
    /p:Configuration="Testing Env"

现在我正在使用TFS构建服务器并尝试使用生成以下命令的Web步骤

"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe"
    -verb:sync
    -source:package='PortalWeb.zip'
    -dest:auto,computerName='https://wwwt.mycompany.ru:8172/msdeploy.axd?site=Portal/test',userName='DeployUser',password='123pwd123',authType='WMSVC',includeAcls='False'
    -allowUntrusted 

此命令因401 Unathorized错误而失败:

2017-06-06T16:00:12.7928227Z ##[error]System.Management.Automation.RemoteException: Error Code: ERROR_USER_UNAUTHORIZED

2017-06-06T16:00:12.7928227Z ##[error]System.Management.Automation.RemoteException: More Information: Connected to the remote computer ("wwwt.mycompany.ru") 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 creden

2017-06-06T16:00:12.7928227Z ##[error]System.Management.Automation.RemoteException: tials represent a user who has permissions to access the site.  Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_UNAUTHORIZED.

2017-06-06T16:00:12.7928227Z Error: The remote server returned an error: (401) Unauthorized.

2017-06-06T16:00:12.7928227Z Error count: 1.

为什么一个命令使用这些凭据而另一个命令失败?

1 个答案:

答案 0 :(得分:1)

确保代理的服务帐户具有部署网站所需的权限。

但更好的方法是在构建过程中创建工件包。这意味着构建并将您的包发布到drop文件夹或tfs内。

之后,您可以使用发布管理部署站点。如果你这样做,有很多好处。