且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MSBuild 可以使用集成身份验证部署还是仅使用基本身份验证?

更新时间:2022-12-06 16:57:04

答案是……

根据我上面关于当前身份的用户名持续到 MSDeploy 命令的编辑,即使未在原始 MSBuild 调用中传递,我尝试重构参数以传递空用户名,如下所示:

Following my edit above about the current identity's username persisting to the MSDeploy command even when not passed in the original MSBuild call, I tried reconstructing the parameters to pass an empty username as follows:

MSBuild.exe Web.csproj
  /p:Configuration=Debug
  /p:DeployOnBuild=True
  /p:DeployTarget=MSDeployPublish
  /p:MsDeployServiceUrl=http://[server name]/MsDeployAgentService
  /p:DeployIisAppPath=DeploymentTestProject
  /p:MSDeployPublishMethod=RemoteAgent
  /p:CreatePackageOnPublish=True
  /p:username=

然后生成以下 MSDeploy 命令:

Which then generates the following MSDeploy command:

msdeploy.exe 
  -source:package='[project path]objDebugPackageWeb.zip' 
  -dest:auto,ComputerName='http://[server name]/MsDeployAgentService',IncludeAcls='False',AuthType='NTLM' 
  -verb:sync 
  -disableLink:AppPoolExtension 
  -disableLink:ContentExtension 
  -disableLink:CertificateExtension 
  -retryAttempts=2

此调用不再包含 UserName 属性.所以简而言之,如果你不向 MSBuild 调用添加用户名参数,它将插入当前身份并推迟到基本身份验证,这将失败,因为没有密码.如果您包含用户名参数但不给它一个值,则它根本不包含在 MSDeploy 命令中.

This call no longer includes the UserName attribute. So in short, if you do not add a username parameter to the MSBuild call it will insert the current identity anyway and defer to basic auth which will fail because there's no password. If you include the username parameter but don't give it a value, it doesn't include it at all in the MSDeploy command.