Visual Studio增量构建:XML文档文件创建太晚了

时间:2023-01-14 19:11:34

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.

我有一个Visual Studio 2005的DLL项目,它打开了“XML文档文件”。每当我进行增量构建时,在构建后事件执行期间,输出目录中都没有XML文档文件。

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.

如果我在构建后事件期间暂停构建(使用GnuWin32 CoreUtils中的sleep实用程序),我可以在输出目录中看到名为vs5BB5.tmp的文件。但是,在完成构建后事件(和“AfterBuild”目标,因为我有一些自定义)之前,此文件不会重命名为MyLib.xml。

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.

对于Studio中的干净构建和从命令行启动的MSBuild,一切都按预期工作 - 在构建后事件之前创建XML文档文件。

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

为什么会这样,我如何修复增量构建?

3 个解决方案

#1


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

刚刚遇到同样的问题。这是Visual Studio和增量构建的已知问题。请参阅microsoft connect上的这篇文章。

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

我用条件xcopy解决了它,如下所示:

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

如果存在“$(TargetDir)$(TargetName).xml”xcopy $(TargetDir)$(TargetName).xml $(ProjectDir)...... \ bin \ / C / I / R / Y

SF

#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.

我发现xml文件被命名为.tmp文件,因此您可以将此tmp文件复制到您想要的位置,这只是一个“混乱”的工作。

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.

唯一的问题是它必须是非阻塞的,你不会知道它是否有效。

#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.

我正在使用一个简单的批处理文件来执行复制,而不是检测tmp文件的默认复制命令,而是复制/重命名它。

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"
)

#1


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

刚刚遇到同样的问题。这是Visual Studio和增量构建的已知问题。请参阅microsoft connect上的这篇文章。

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

我用条件xcopy解决了它,如下所示:

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

如果存在“$(TargetDir)$(TargetName).xml”xcopy $(TargetDir)$(TargetName).xml $(ProjectDir)...... \ bin \ / C / I / R / Y

SF

#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.

我发现xml文件被命名为.tmp文件,因此您可以将此tmp文件复制到您想要的位置,这只是一个“混乱”的工作。

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.

唯一的问题是它必须是非阻塞的,你不会知道它是否有效。

#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.

我正在使用一个简单的批处理文件来执行复制,而不是检测tmp文件的默认复制命令,而是复制/重命名它。

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"
)