2014-01-09 31 views
3

在对我的项目进行了一些更改后,Visual Studio开始总是重新编译所有源代码,导致所有依赖项目也重新编译,从而显着减慢了开发速度。这是为什么?Visual Studio总是重新编译代码,即使它没有改变

  • 只有在检测到XML documentation file并且有一些文件与Copy always时才会发生。如果您更改其中任何一项,则不会重新编译源代码。
  • 只有在Visual Studio内编译时才会发生 - 编译时使用命令行中的MSBuild时,不会重新编译源代码。
  • 的Visual Studio 2012更新4
+0

我使用VS 2013更新2,我看到相同的不想要的行为:当源代码没有发生任何更改时重新编译项目。即使我没有在我的解决方案的任何项目中选中“XML文档文件”,也会发生这种情况。所以还有其他原因。 :-( – farfareast

+0

好吧,你可以在下面我的回答中对它进行调查,并报告你的发现。 – Jonathan

回答

1

这似乎是在Visual Studio中的一个bug,当项目有XML documentation file查了一些文件与Copy always

摄制:

  1. 创建新项目 - C#类库。
  2. 项目属性=>生成=>检查XML documentation file
  3. 项目=>添加=>新项目=>文本文件TextFile1.txt
  4. 变化TextFile1.txt Copy to Output DirectoryCopy always
  5. 右击项目=>打造
    • 项目编译
  6. 右击项目=>建立

预计:项目不应该建,建输出应该说:

========== 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 ========== 

Intestigation:车削在详细日志中,您会看到:

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,你会发现在MSBuild.exe运行之前,devenv.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 
相关问题