代码之家  ›  专栏  ›  技术社区  ›  VladV

Visual Studio增量生成:XML文档文件创建太晚

  •  4
  • VladV  · 技术社区  · 16 年前

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

    如果在生成后事件期间暂停生成(使用来自 GnuWin32 CoreUtils ,我可以在输出目录中看到名为vs5bb5.tmp的文件。但在完成生成后事件(和“afterbuild”目标,因为我在那里有一些自定义设置)之前,不会将此文件重命名为mylib.xml。

    对于在Studio中的干净生成和从命令行启动的msbuild,一切工作正常-在生成后事件之前创建XML文档文件。

    为什么会发生这种情况,以及如何修复增量构建?

    3 回复  |  直到 14 年前
        1
  •  3
  •   A Guy From Ottawa    15 年前

    只是有同样的问题。这是Visual Studio和增量生成的已知问题。参见 this post on microsoft connect .

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

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

    旧金山

        2
  •  1
  •   Keith Nicholas    15 年前

    我自己也有这个问题……

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

    我也很想给自己写一个命令行工具,叫做:

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

    唯一的问题是它必须是非阻塞的,你不知道它是否工作。

        3
  •  1
  •   Jonas    14 年前

    我使用一个简单的批处理文件来进行复制,而不是使用默认的copy命令来检测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"
    )