Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy Failed during post-build process

I am writing an ASP.NET web application using Visual Studio 2008. The project is mostly unchanged from the default empty project that Visual Studio provides, except for:

  • In Properties->Build->Output, "XML documentation file" is checked and set to "bin\MyProject.XML"
  • In Properties->Build Events, "Post-build event command line:" is set to copy /y "$(TargetDir)$(TargetName).XML" "C:\TEMP\"

When I build the project for the first time, or rebuild, the build process completes successfully. If I try to build any time after that, however, the build process fails with this message:

------ 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 ==========

I'm certain that the syntax is correct, because I can perform the post-build command in a command window:

C:\>copy /y "C:\Projects\MyProject\MyProject\bin\MyProject.XML" "C:\TEMP\"
        1 file(s) copied.

The command works when I do it manually, so why does it fail when it is part of the build process?

like image 379
Kevin Avatar asked Dec 06 '11 13:12

Kevin


1 Answers

There is a flaw in the underlying msbuild tasks that are used by Visual Studio when the XML documentation file is generated in the same directory as the one specified as the output path, for intermediary builds.

To fix it, you need to specify a different directory, for example, like this:

enter image description here

and change your post-build copy command accordingly, like this:

copy /y "C:\Projects\MyProject\MyProject\docbin\Debug\MyProject.XML" "C:\TEMP\"
like image 61
Simon Mourier Avatar answered Sep 27 '22 19:09

Simon Mourier