我正在尝试使用 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=""$(MsDeployBinary)" -verb:delete -dest:auto,computerName="https://$(PublishServer):8172/msdeploy.axd?Site=$(IisAppHostName)",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=""$(MsDeployBinary)" -verb:sync -source:package="$(ArchiveDir)\$(SiteName)\$(SiteName).zip" -dest:auto,computerName="https://$(PublishServer):8172/msdeploy.axd?Site=$(IisAppHostName)",authType=Basic,userName=$(UserName),password='$(Password)' -allowUntrusted -setParam:"IIS Web Application Name"="$(IisAppHostName)/$(IisSiteName)""
/>
<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=""$(MsDeployBinary)" -verb:delete -dest:iisApp="$(IisAppHostName)/$(IisSiteName)",computerName="https://$(PublishServer):8172/msdeploy.axd?Site=$(IisAppHostName)",authType=Basic,userName=$(UserName),password='$(Password)' -allowUntrusted -disableLink:ContentExtension -disableLink:AppPoolExtension"
/>