gpt4 book ai didi

visual-studio-2008 - 在构建后过程中复制失败

转载 作者:行者123 更新时间:2023-12-05 00:36:10 24 4
gpt4 key购买 nike

我正在使用 Visual Studio 2008 编写 ASP.NET Web 应用程序。
该项目与 Visual Studio 提供的默认空项目基本没有变化,除了:

  • 在 Properties->Build->Output 中,选中“XML 文档文件”并将其设置为“bin\MyProject.XML”
  • 在“属性”->“构建事件”中,“构建后事件命令行:”设置为 copy /y "$(TargetDir)$(TargetName).XML" "C:\TEMP\"

  • 当我第一次构建项目或重建时,构建过程成功完成。
    但是,如果我在此之后的任何时间尝试构建,构建过程都会失败并显示以下消息:
    ------ 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 ==========

    我确定语法是正确的,因为我可以在命令窗口中执行 post-build 命令:
    C:\>copy /y "C:\Projects\MyProject\MyProject\bin\MyProject.XML" "C:\TEMP\"
    1 file(s) copied.

    该命令在我手动执行时有效,那么为什么在构建过程中它会失败?

    最佳答案

    当 XML 文档文件在与指定为输出路径的目录相同的目录中生成时,Visual Studio 使用的底层 msbuild 任务存在缺陷,用于中间生成。

    要修复它,您需要指定一个不同的目录,例如,像这样:

    enter image description here

    并相应地更改您的构建后复制命令,如下所示:

    copy /y "C:\Projects\MyProject\MyProject\docbin\Debug\MyProject.XML" "C:\TEMP\"

    关于visual-studio-2008 - 在构建后过程中复制失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8401055/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com