Tutorial :Visual Studio incremental build: XML documentation file is created too late



Question:

I have a DLL project for Visual Studio 2005 that has "XML documetation file" turned on. Whenever I do an incremental build, during post-build event execution there is no XML documentation file in the output directory.

If I pause the build during post-build event (using sleep utility from GnuWin32 CoreUtils), I can see the file in the output directory with a name like vs5BB5.tmp. But this file is not renamed to MyLib.xml until post-build event (and "AfterBuild" target, as I have some customizations there) are finished.

For a clean build in Studio and for MSBuild started from a command line everything works as expected - XML documentation file is created before post-build events.

Why this happens, and how do I fix incremental builds?


Solution:1

Was just having the same issue. This is a known problem with Visual Studio and incremental builds. See this post on microsoft connect.

I solved it with a conditional xcopy like the one below:

if exist "$(TargetDir)$(TargetName).xml" xcopy $(TargetDir)$(TargetName).xml $(ProjectDir)......\bin\ /C /I /R /Y

SF


Solution:2

Just having this problem myself....

what I found is that the xml file is named a .tmp file, so you can copy this tmp file to where you want, its just a bit of a "messy" work around.

I'm also quite tempted to write myself a command line tool thats called something like :-

WaitForThenCopy <source path> <target path> <milliseconds to wait>  

only problem is it would have to be non blocking and you wouldn't know if it worked or not.


Solution:3

I'm using a simple batch file to do the copying instead of the default copy command that detects the tmp file and copies/renames this instead.

REM There is a bug in VS where the xml documentation is written to a tmp file  REM during incremental builds, preventing access during post-build events.  REM See http://connect.microsoft.com/VisualStudio/feedback/details/470485/strange-file-not-found-error-xml-documentation-file-renamed-during-incremental-build  REM As a work around for following script tries to catch this situation and copys/remanes  REM this tmp-file instead.    REM .SYNOPSIS  REM CopyXmlDocumentation "X:\path\to\source.xml" "Y:\target\dir"    if exist "%~1%" (    REM if the file exists, copy it as-is    copy /Y "%~1" "%~2"  ) else (    REM else we try to copy the .tmp file and rename it to the desired target name    REM we assume that the tmp file is named "vsXXXX.tmp" where XXXX is an arbitrary string    copy /Y "%~d1\%~p1\vs*.tmp" "%~2\%~n1%~x1"  )  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »