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

VS2017构建后事件执行文件复制时出现9009退出代码错误

问题:VS2017构建后事件多命令执行报错(错误码9009)

我需要通过VS2017的构建后事件完成两个操作:将项目文件夹中的一组文件复制到输出文件夹,同时如果目标路径下的Settings文件夹不存在则创建它。我编写了以下构建后事件脚本:

SET path=$(TargetDir)Config\Settings
if not exist "%path%" mkdir "%path%"
xcopy "$(SolutionDir)\Application\Resources" "$(TargetDir)Config\Settings"

执行时出现错误,错误信息如下:

The command "SET path=C:\Users\User1\Documents\Repo\bin\Config\Settings
if not exist "%path%" mkdir "%path%"
xcopy "C:\Users\User1\Documents\Repo\Sample\Application\Resources" 
"C:\Users\User1\Documents\Repo\bin\Config\Settings"" exited with code 9009.

单独执行前两行命令时,可以正常创建目标文件夹;单独执行第三行命令时,文件也能正常复制,但三条命令一起执行就会触发上述错误。


解决方法

通过指定xcopy.exe的绝对路径即可解决该问题。修改后的脚本示例:

SET path=$(TargetDir)Config\Settings
if not exist "%path%" mkdir "%path%"
%SystemRoot%\System32\xcopy.exe "$(SolutionDir)\Application\Resources" "$(TargetDir)Config\Settings"

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.25 12:53:11