简体   繁体   English

无法在 linux 上使用 Visual Studio 代码调试 C# 测试

[英]Cannot debug C# tests with visual studio code on linux

I have a c# project which I want to unit test.我有一个 c# 项目,我想对其进行单元测试。 I'm trying to simply debug a unit test in VSCode running on linux, but I get the following error:我试图简单地调试在 linux 上运行的 VSCode 中的单元测试,但出现以下错误:

Failed to start debugger: "System.ArgumentException: '' is not a valid version string.
Parameter name: value
 at NuGet.Versioning.SemanticVersion.Parse (System.String value) [0x0001c] in <0fb3faba525e4e72954446a9b4e57f5b>:0
  at OmniSharp.Services.DotNetCliService.GetVersion (System.String workingDirectory) [0x00011] in <7c5a61c964114ca68a62c9da132f5af2>:0
  at OmniSharp.DotNetTest.TestManager.Create (Microsoft.CodeAnalysis.Project project, OmniSharp.Services.IDotNetCliService dotNetCli, OmniSharp.Eventing.IEventEmitter eventEmitter, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory) [0x0000c] in <f766edfe7c324a8d817379aedddb5887>:0
  at OmniSharp.DotNetTest.TestManager.Start (Microsoft.CodeAnalysis.Project project, OmniSharp.Services.IDotNetCliService dotNetCli, OmniSharp.Eventing.IEventEmitter eventEmitter, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, System.Boolean noBuild) [0x00000] in <f766edfe7c324a8d817379aedddb5887>:0
  at OmniSharp.DotNetTest.Services.BaseTestService.CreateTestManager (System.String fileName, System.Boolean noBuild) [0x00011] in <f766edfe7c324a8d817379aedddb5887>:0
  at OmniSharp.DotNetTest.Services.DebugTestService.Handle (OmniSharp.DotNetTest.Models.DebugTestGetStartInfoRequest request) [0x0000d] in <f766edfe7c324a8d817379aedddb5887>:0
  at OmniSharp.Endpoint.Exports.RequestHandlerExportHandler`2[TRequest,TResponse].Handle (TRequest request) [0x00000] in <7c5a61c964114ca68a62c9da132f5af2>:0 
  at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].GetFirstNotEmptyResponseFromHandlers (OmniSharp.Endpoint.Exports.ExportHandler`2[TRequest,TResponse][] handlers, TRequest request) [0x00022] in <7c5a61c964114ca68a62c9da132f5af2>:0
  at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].HandleRequestForLanguage (System.String language, TRequest request, OmniSharp.Protocol.RequestPacket packet) [0x00163] in <7c5a61c964114ca68a62c9da132f5af2>:0
  at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].Process (OmniSharp.Protocol.RequestPacket packet, OmniSharp.Endpoint.LanguageModel model, Newtonsoft.Json.Linq.JToken requestObject) [0x0024b] in <7c5a61c964114ca68a62c9da132f5af2>:0
  at OmniSharp.Stdio.Host.HandleRequest (System.String json, Microsoft.Extensions.Logging.ILogger logger) [0x000f3] in <a50105da3f9c45b299f1e289aba046fa>:0 "

It is an empty test project with the auto generated test method.它是一个带有自动生成的测试方法的空测试项目。 It is a mstest project but it also throws the same error in an xunit test project.这是一个 mstest 项目,但它也在 xunit 测试项目中抛出相同的错误。

Does anyone know what I'm missing?有谁知道我错过了什么?

I had a similar problem (VSCode, Linux, not a valid version string, though mine was null, not an empty string, mstest).我遇到了类似的问题(VSCode,Linux,不是有效的版本字符串,尽管我的是 null,不是空字符串,mstest)。 It turned out that simply restarting VSCode resolved the issue, and I could run the debugger.事实证明,只需重新启动 VSCode 即可解决问题,我可以运行调试器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM