【问题标题】:How to prevent Visual Studio from building the project every time?如何防止 Visual Studio 每次都构建项目?
【发布时间】:2018-05-08 19:08:00
【问题描述】:

当我右键单击一个项目并选择构建时,它每次都会构建它,尽管我刚刚构建了它并且项目并没有过期。

我已按照winning answer to a similar question 中的说明进行操作,但这并没有解决我的问题。

我还检查了 Options/Project and Solutions/Build and Run 设置是否正确。我打开了详细的构建输出,但没有看到任何明显的东西。输出在这里:Part 1 和 Part 2。项目本身 if here.

唯一值得怀疑的是:

1>Project file contains ToolsVersion="4.0". This toolset may be unknown or missing

项目文件中没有ToolsVersion=4.0。

【问题讨论】:

  • 您的项目最初创建的 .net 框架是什么?哪个版本的视觉工作室?
  • 也许我不明白什么,但在日志中说:Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files. | Build: 1 succeeded, 0 failed, 1 up-to-date, 0 skipped。关于参考:Did not copy from file "obj\$Reference" to file "bin\$Reference" because the "SkipUnchangedFiles" parameter was set to "true" in the project and the files sizes and timestamps match.您的项目没有重建。
  • @FrancescoB。没有把握。它至少有 15 岁。我假设.NET 2.0

标签: c# .net visual-studio msbuild visual-studio-2017


【解决方案1】:

回答我自己的问题,以防有人遇到类似问题。问题是项目中的某些文件(二进制文件和其他非 c# 文件)被设置为Content/Copy Always。我将它们更改为 Content/Copy if Newer 并解决了问题。

【讨论】:

  • 我记得很久以前我也遇到过同样的问题。在浏览构建日志时,您应该能够跟踪到这一点。有时,工具也有帮助,以结构化方式查看日志,例如 msbuild log viewer msbuildlog.com)。
  • @Styxxy 诀窍是将构建日志设置为Diagnostic 而不是Detailed。详细模式没有显示我正在寻找的任何信息。
  • 确实!现在你说出来,它敲响了警钟。不过,在进行故障排除时,我通常将日志放在诊断上:-)。
猜你喜欢
  • 2013-05-19
  • 2012-04-29
  • 1970-01-01
  • 1970-01-01
  • 2011-05-29
  • 2017-04-01
  • 2021-05-25
  • 1970-01-01
  • 2021-10-21
相关资源
最近更新 更多