我正在使用 Visual Studio 2008 编写一个 ASP.NET Web 应用程序。该项目与 Visual Studio 提供的默认空项目基本没有变化,除了:
- 在 Properties->Build->Output 中,“XML 文档文件”被选中并设置为“bin\MyProject.XML”
- 在 Properties->Build Events 中,“Post-build event command line:”设置为
copy /y "$(TargetDir)$(TargetName).XML" "C:\TEMP\"
当我第一次构建项目或重新构建项目时,构建过程成功完成。但是,如果我在此之后的任何时间尝试构建,构建过程将失败并显示以下消息:
------ Build started: Project: MyProject, Configuration: Debug Any CPU ------
MyProject -> C:\Projects\MyProject\MyProject\bin\MyProject.dll
copy /y "C:\Projects\MyProject\MyProject\bin\MyProject.XML" "C:\TEMP\"
The system cannot find the file specified.
c:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets(3397,13): error MSB3073: The command "copy /y "C:\Projects\MyProject\MyProject\bin\MyProject.XML" "C:\TEMP\"" exited with code 1.
Done building project "MyProject.csproj" -- FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
我确定语法是正确的,因为我可以在命令窗口中执行构建后命令:
C:\>copy /y "C:\Projects\MyProject\MyProject\bin\MyProject.XML" "C:\TEMP\"
1 file(s) copied.
该命令在我手动执行时有效,那么为什么它在构建过程中会失败?