【问题标题】:Visual Studio incremental build: XML documentation file is created too lateVisual Studio 增量构建:XML 文档文件创建得太晚
【发布时间】:2011-05-26 21:23:07
【问题描述】:

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

如果我在构建后事件期间暂停构建(使用来自GnuWin32 CoreUtils 的睡眠实用程序),我可以在输出目录中看到名称类似于 vs5BB5.tmp 的文件。但是在构建后事件(以及“AfterBuild”目标,因为我在那里进行了一些自定义)完成之前,此文件不会重命名为 MyLib.xml。

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

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

【问题讨论】:

    标签: visual-studio visual-studio-2005 msbuild


    【解决方案1】:

    刚刚遇到同样的问题。这是 Visual Studio 和增量构建的一个已知问题。见this post on microsoft connect

    我用一个有条件的 xcopy 解决了这个问题,如下所示:

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

    SF

    【讨论】:

    【解决方案2】:

    我自己也有这个问题....

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

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

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

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

    【讨论】:

      【解决方案3】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-10-28
        • 2021-05-23
        • 2012-12-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-01-05
        相关资源
        最近更新 更多