You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用msdeploy迁移IIS 10时遇“文件已存在无法创建”错误求助

IIS 10服务器迁移时MSDeploy报错:无法创建已存在的文件

我们尝试使用以下命令将IIS 10从一台服务器迁移至另一台:

msdeploy -verb:sync -source:webServer,computername=academicApp01T -dest:webServer,computername=WEBAAPPT01WA, -enablelink:AppPoolExtension -disableLink:Content -replace:objectName=metaProperty,scopeAttributeName=name,scopeAttributeValue="ServerBindings",match=sourceIP,replace=newdestinationIP

已安装MSDeploy的「完整」版本(非自定义/典型版本),但持续出现如下错误:

C:\Program Files\IIS\Microsoft Web Deploy V3>msdeploy -verb:sync -source:webServer,computername=academicApp01T -dest:webServer,computername=WEBAAPPT01WA, -enablelink:AppPoolExtension -disableLink:Content -replace:objectName=metaProperty,scopeAttributeName=name,scopeAttributeValue="ServerBindings",match=sourceIP,replace=newdestinationIP
Info: Using ID 'ab29a6b0-c2d7-4e0c-afad-f410a54db50c' for connections to the remote server.
Info: Using ID '830a233d-98f3-4a9a-ab8e-c4437cb94b92' for connections to the remote server.
Info: Updating section (MSDeploy.webServer/webServer/appHostConfig[@path='']/configSections/sectionGroup[@name='system.webServer']/section[@name='httpCompression']).
Info: Adding child appHostConfig (MSDeploy.webServer/webServer/appHostConfig[@path='']/location[@path='']).
Error: (12/28/2023 9:36:54 AM) An error occurred when the request was processed on the remote computer.
Error: Cannot create a file when that file already exists. (Exception from HRESULT: 0x800700B7)

解决方法

1. 排查目标服务器的重复配置节点

根据日志中的httpCompression和空路径location节点提示,目标服务器的applicationHost.config(路径:C:\Windows\System32\inetsrv\config\applicationHost.config)大概率已存在相同配置项。打开该文件搜索httpCompression,删除重复的配置段后重试同步。

2. 添加跳过规则避免冲突

在原命令中加入-skip参数,跳过已存在的冲突节点:

  • 跳过httpCompression配置:
msdeploy -verb:sync -source:webServer,computername=academicApp01T -dest:webServer,computername=WEBAAPPT01WA -enablelink:AppPoolExtension -disableLink:Content -replace:objectName=metaProperty,scopeAttributeName=name,scopeAttributeValue="ServerBindings",match=sourceIP,replace=newdestinationIP -skip:objectName=section,scopeAttributeName=name,scopeAttributeValue=httpCompression
  • 若为空路径location节点冲突,追加:
-skip:objectName=location,scopeAttributeName=path,scopeAttributeValue=""

3. 重置目标服务器IIS默认配置

如果目标服务器是新部署的,先重置IIS配置到默认状态,再执行迁移命令:

%windir%\system32\inetsrv\appcmd reset config

4. 验证执行账号权限

确保执行命令的账号在目标服务器拥有管理员权限,权限不足可能导致配置写入时抛出异常错误。

内容的提问来源于stack exchange,提问作者gabriel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 10:17:19