自 Visual Studio 2017 版本 15.8 以来持续构建失败 (Roslyn/CodeAnalysis)。有任何想法吗?

Constant build failure (Roslyn/CodeAnalysis) since Visual Studio 2017 version 15.8. Any ideas?

自 Visual Studio 2017 版 15.8 以来,我们团队中的某些计算机出现了以下非常奇怪的构建错误。

另外Visual Studio认得

但是 IDE 本身并没有崩溃。

为了检查它是否只发生在我们自己的解决方案中,我创建了一个新的简单明了的命令行工具项目,它显示了相同的构建行为。所以它不是我们解决方案所独有的。

我试图获得 help from Microsoft,但他们似乎不知道该怎么做。该线程没有显示我提供给他们的所有 material。他们从我那里得到了很多日志和一个示例项目。无法提供故障转储,因为 Visual Studio 本身不会崩溃。

修复并完全卸载,Visual Studio 的新安装也没有帮助。

编辑:它不仅发生在我的开发机器上,也发生在我们的构建服务器上(有两个)。有趣的是,我们在开发机器上的 VM 似乎没有这个问题。

不幸的是,在这种情况下你只有三个两个选项:

  1. 您可以尝试尽可能详细地描述重现此崩溃的所有步骤,并使用这些步骤中的大量屏幕截图。用于此 DOC 文件格式、PDF 或类似格式。您必须将此文件发送给 Visual Studio 支持。
  2. 您可以尝试创建故障转储。每次 Visual Studio 崩溃时,它都会在配置的位置创建一个转储文件 devenv.exe.[number].dmp 文件。此方法生成的每个转储文件的大小将达到 4 GB.。确保将 DumpFolder 设置为具有足够驱动器 space 的位置或适当调整 DumpCount。我知道,您已经在 MS 论坛上写道,此错误不会创建一个转储。但是你想想象一下你一天有 10 次崩溃,每次崩溃都会写入一个大小为 4 GB. 的转储文件吗? 转储创建通常被禁用,您必须启用它。如何启用它,您可以使用 Google 中的搜索字符串找到:“How to enable dump files in Windows" or for Windows 10 you could see this video. Alternatively or additionally you could use the programm tool "ADPlus" for creating memory dump files and log files with debug output from one or more processes. This tool is very detailed describen on this MS Support page.
  3. 你可以尝试自己调试。但是如果你想调试的话,你必须看到“Tools listing Included in Debugging Tools for Windows”。

通常由 Visual Studio 支持不工作 Visual Studio 开发人员。你必须对他们好,他们会做他们能做的。你不能期望他们都知道。他们使用一些给定的指令来完成工作。

在你的情况下,支持人员给了你 link Reporting Visual Studio crashes and performance issues,你必须阅读以下部分:

Directly reproducible crashes

Directly reproducible crashes are cases which have all of the following characteristics:

  1. Can be observed by following a known set of steps
  2. Can be observed on multiple computers (if available)
  3. If the steps involve opening a project or document, can be reproduced in sample code or a project which can be linked to or provided as part of the feedback

For these issues, follow the steps in "How to Report a Problem" and be sure to include:

  • The steps to reproduce the problem
  • A standalone repro project as described above. If this is not possible, then please include:

    • The language of the open projects (C#, C++, etc.)
    • The kind of project (Console Application, ASP.NET, etc.)
    • Any extensions that are installed.

Most valuable feedback: For this case, the most valuable feedback is the set of steps to reproduce the issue along with sample source code.

Unknown crashes

If you're not sure what's causing your crashes or they seem random, then you can capture dumps locally each time Visual Studio crashes and attach those to separate feedback items. To save dumps locally when Visual Studio crashes, set the following registry entries:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\devenv.exe]
"DumpFolder"="C:\Crashdumps"
"DumpCount"=dword:00000005
"DumpType"=dword:00000002

⚠️ Each dump file produced by this method will be up to 4 GB. in size. Make sure to set DumpFolder to a location with adequate drive space or adjust the DumpCount appropriately.

Each time Visual Studio crashes, it will create a dump file devenv.exe.[number].dmp file in the configured location.

Then, use Visual Studio's "Report a Problem..." feature. It will allow you to attach the appropriate dump.

  1. Locate the dump file for the crash you are reporting (look for a file with the correct Creation time)
  2. If possible, zip the file (*.zip) to reduce its size before submitting feedback
  3. Follow the steps in "How to Report a Problem", and attach the heap dump to a new feedback item.

⚠️ Do not attach heap dumps to existing feedback items. Please create a new feedback item for each heap dump you would like to submit. If you were requested to provide a heap dump in order to resolve a previous feedback item, simply reply to the request with a link to the new feedback item where the heap dump is attached.

Most valuable feedback: For this case, the most valuable feedback is the heap dump captured at the time of the crash.

仔细阅读,在最好的情况下连续两次甚至树次

希望对你有所帮助,祝你好运!

在我看来,问题与从 GAC 加载程序集有关,所以我建议尝试重新安装 Microsoft.CodeAnalysis 程序集,看看是否有帮助。

这样做:

  1. Microsoft.CodeAnalysis 包安装到您的项目,并确保记下所有正在下载的程序集。
  2. 运行 Visual Studio 作为管理员的开发人员命令提示符
  3. 使用命令 gacutil /u [name of assembly] 从 GAC 卸载现有程序集(对步骤 1 中的所有程序集执行此操作)
  4. 使用命令 gacutil /u [Path to Dll] 为所有 dll 安装新下载的 dll(对步骤 1 中的所有程序集执行此操作)
  5. 从您的项目中删除包

希望对您有所帮助!

正如 Dipen 在另一个答案中所建议的,问题似乎在 Microsoft.CodeAnalysis 中,尝试为此重新安装 nuget 包,如果丢失则在 GAC 中重新注册。

如果问题仍然存在,您可以尝试对您的项目禁用代码分析,例如:

  1. 在 VS 2017 中的项目中,打开 References 并右键单击 Analyzers,然后单击打开 Active Rule Set,如下所示:

  2. 取消选中所有规则,这样就不会对您的项目进行任何代码分析,例如:

3.保存所有文件,现在尝试重建 & 运行 项目以查看问题是否已解决。

问题是安装了较旧的 JustMock 版本。只能在Roslyn团队的帮助下解决了。