这似乎是 Visual Studio 中的一个错误,当项目有 XML documentation file 检查带有 Copy always 的一些文件时。
复制:
- 创建新项目 - C# 类库。
- 项目属性 => 构建 => 检查
XML documentation file
- 项目 => 添加 => 新项目 => 文本文件
TextFile1.txt
- 将 TextFile1.txt
Copy to Output Directory 更改为 Copy always
- 右键单击项目 => 构建
- 右键单击项目 => 构建
预期:不应构建项目,构建输出应显示:
========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
实际:项目正在构建,输出为:
------ Build started: Project: ClassLibrary1, Configuration: Debug Any CPU ------
ClassLibrary1 -> bin\Debug\ClassLibrary1.dll
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
调查:打开详细日志,您会看到:
Target "CoreCompile" in file "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.CSharp.targets" from project "ClassLibrary1.csproj" (target "Compile" depends on it):
Building target "CoreCompile" completely.
Output file "bin\Debug\ClassLibrary1.XML" does not exist.
查看 procmon,您会看到 devenv.exe 在 MSBuild.exe 运行之前将“ClassLibrary1.XML”重命名为“vsA381.tmp”。重命名的堆栈跟踪:
KERNEL32!MoveFileW+0x17
csproj!CMoveOutOfTheWayScope::EnterScope+0x85
csproj!CVsProjBuildableProjectCfg::StartBuildProcessWithTarget+0x50b
csproj!CVsProjBuildableProjectCfg::StartBuildProcess+0xc
csproj!CVsProjBuildableProjectCfg::StartBuildEx+0x15
msenv!CSUIBuilder::DoBuild+0x1a3
msenv!CSUIBuilder::Run+0x66