Can MSBuild deploy using integrated authentication or only basic?

前端 未结 5 2226
离开以前
离开以前 2020-12-07 11:42

I\'m deploying a web app package from the MSBuild command line to MSDepSvc on IIS6 which is working fine with the following command using basic authentication:



        
相关标签:
5条回答
  • 2020-12-07 11:59

    Breaking the process into 2 steps worked for me -

    1. Build & Package

      msbuild.exe /p:DeployOnBuild=True /p:WebPublishMethod=Package /p:PackageAsASingleFile=true /p:AllowUntrustedCertificate=True /p:CreatePackageOnPublish=True /p:SkipExtraFilesOnServer=True /p:PublishProfile=DevProfile /p:Configuration=dev

    2. Deploy

      msdeploy.exe -source:package='C:\packagelocation\dev.zip' -dest:auto,ComputerName='http://destinationserver/MsDeployAgentService',IncludeAcls='False',AuthType='NTLM' -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -retryAttempts=2

    0 讨论(0)
  • 2020-12-07 11:59

    This worked, I initially was distracted by the targets file but realised my error was in the connection string, i.e. was trying to use https instead of http.

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

    0 讨论(0)
  • 2020-12-07 12:06

    I was able to get NTLM working as follows where the service is running under an account with admin privs on [server name].

    "C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" app\Test.Web\Test.Web.csproj /T:Clean /T:Package /P:Configuration=Release

    C:\hudson\jobs\Test\workspace\app\Test.Web\obj\Release\Package\Test.Web.deploy.cmd /Y "/M:http://[server name]/MSDEPLOYAGENTSERVICE" /A:ntlm -allowUntrusted

    which generates:

    "C:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe" -source:package='C:\hudson\jobs\Test\workspace\app\Test.Web\obj\Release\Package\Test.Web.zip' -dest:auto,computerName='http://[server name]/MSDEPLOYAGENTSERVICE',authtype='ntlm',includeAcls='False' -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:"C:\hudson\jobs\Test\workspace\app\Test.Web\obj\Release\Package\RapidPrototypeRequestSystem.Web.SetParameters.xml" -allowUntrusted

    0 讨论(0)
  • 2020-12-07 12:07

    And the answer is...

    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=
    

    Which then generates the following MSDeploy command:

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

    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.

    0 讨论(0)
  • 2020-12-07 12:08

    I looked in the Microsoft.Web.Publishing.targets and saw this:

    <PropertyGroup>
      <NormalizePublishSettings ...>
      <AuthType Condition="'$(AuthType)'==''" >Basic</AuthType>
      <!--Supported value for $(MSDeployPublishMethod): WMSVC, RemoteAgent, InProc-->
      <MSDeployPublishMethod ... >WMSVC</MSDeployPublishMethod>
      ...
    </PropertyGroup>
    

    So, it looks like the default is Basic authentication when running from MSBuild. Then I found this http://technet.microsoft.com/de-de/library/dd569001(WS.10).aspx

    authenticationType specifies the type of authentication to be used. The possible values are NTLM and Basic. If the wmsvc provider setting is specified, the default authentication type is Basic; otherwise, the default authentication type is NTLM.

    I haven't tried it yet, but maybe it's something like /p:AuthType=NTLM

    0 讨论(0)
提交回复
热议问题