Msdeploy,可以同步但不能删除

Msdeploy,可以同步但不能删除

我正在尝试使用 msbuild 设置自动部署。
我成功进行了 msdeploy 同步调用,成功发布了使用 msbuild 创建的 zip 包。
但是,当我尝试在同步操作之前执行 msdeploy 删除调用时,它失败了

错误_用户_未获得部署提供商的授权

与用于同步调用的权限或附加 IIS 委派规则相比,是否需要设置任何权限或附加 IIS 委派规则?

正确工作msdeploy -verb:sync

  Total changes: 676 (672 added, 0 deleted, 4 updated, 0 parameters changed, 55787329 bytes copied)
  Syncing done.

然而msdeploy -verb:delete失败了:

  Info: Using ID '138cbadf-3449-4574-8e3f-0a3bd13fe751' for connections to the remote server.
EXEC : error Code: ERROR_USER_NOT_AUTHORIZED_FOR_DEPLOYMENTPROVIDER [c:\PATH\Deploy.proj]
  More Information: Could not complete an operation with the specified provider ("auto") when connecting using the Web Management Service. This can o
  ccur if the server administrator has not authorized the user for this operation. auto http://go.microsoft.com/fwlink/?LinkId=178034
    Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_NOT_AUTHORIZED_FOR_DEPLOYMENTPROVIDER.

如您所见,我正在使用 msbuild proj 文件来完成此操作。msdeploy 调用按照以下<Exec>规则执行:

<Target Name="Publish" >
        <Message Importance="High" Text="Deleting from $(PublishServer) ..." />
        <!-- THIS FAILS: -->
        <Exec
          WorkingDirectory="$(MsDeployBinaryFolder)\"
          Command="&quot;$(MsDeployBinary)&quot; -verb:delete -dest:auto,computerName=&quot;https://$(PublishServer):8172/msdeploy.axd?Site=$(IisAppHostName)&quot;,authType=Basic,userName=$(UserName),password='$(Password)' -allowUntrusted -disableLink:ContentExtension -disableLink:AppPoolExtension"
        />
        <Message Importance="High" Text="Deletion done." />


        <Message Importance="High" Text="Syncing to $(PublishServer) ..." />
        <!-- THIS WORKS: -->
        <Exec
          WorkingDirectory="$(MsDeployBinaryFolder)\"
          Command="&quot;$(MsDeployBinary)&quot; -verb:sync -source:package=&quot;$(ArchiveDir)\$(SiteName)\$(SiteName).zip&quot; -dest:auto,computerName=&quot;https://$(PublishServer):8172/msdeploy.axd?Site=$(IisAppHostName)&quot;,authType=Basic,userName=$(UserName),password='$(Password)' -allowUntrusted -setParam:&quot;IIS Web Application Name&quot;=&quot;$(IisAppHostName)/$(IisSiteName)&quot;"
        />
        <Message Importance="High" Text="Syncing done." />
  </Target>

知道为什么同步可以添加和更改文件而删除却失败吗?

答案1

好的,使用-dest:issApp而不是-dest:auto提供程序就可以了。
奇怪的是,我无法-dest:iisApp在从源包同步时使用提供程序,否则会收到事件错误:

Microsoft.Web.Deployment.DeploymentException:源(sitemanifest)和目标(iisApp)对于给定的操作不兼容。

因此我使用-dest:auto进行同步,使用-dest:iisApp进行删除。

<Exec
          WorkingDirectory="$(MsDeployBinaryFolder)\"
          Command="&quot;$(MsDeployBinary)&quot; -verb:delete -dest:iisApp=&quot;$(IisAppHostName)/$(IisSiteName)&quot;,computerName=&quot;https://$(PublishServer):8172/msdeploy.axd?Site=$(IisAppHostName)&quot;,authType=Basic,userName=$(UserName),password='$(Password)' -allowUntrusted -disableLink:ContentExtension -disableLink:AppPoolExtension"
        />

相关内容