简体   繁体   中英

Cannot debug C# tests with visual studio code on linux

I have a c# project which I want to unit test. I'm trying to simply debug a unit test in VSCode running on linux, but I get the following error:

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.

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). It turned out that simply restarting VSCode resolved the issue, and I could run the debugger.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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