OmniSharp/omnisharp-roslyn

OmniSharp.SdkInstanceProvider fails to parse 'omnisharp.sdkVersion' and 'omnisharp.sdkPath'

BBergquist opened this issue · 7 comments

Repro (using the latest version of OmniSharp w/ omnisharp.useModernNet enabled):

  1. Override omnisharp.sdkVersion or omnisharp.sdkPath with any value (including the recommended values: "6.0.300" or "/home/username/dotnet/sdks/6.0.300").
  2. Restart OmniSharp.

Expected behavior: OmniSharp successfully restarts, finding the specified SDK version from the user settings.

Actual behavior: [fail]: OmniSharp.MSBuild.Discovery.Providers.SdkInstanceProvider The Sdk version specified in the OmniSharp settings was not a valid semantic version. Configured version is ''6.0.300''. Please update your settings and restart OmniSharp.

I checked the regex found in the code. 6.0.300 (no quotes) is a valid semantic version, but '6.0.300' is not. That paired with the logging message showing double ticks suggests that OmniSharp is receiving the setting value with extra quotes and needs to strip them out.

The impact is that this bug prevents users from building .NET Core 3.1 SDK-style projects.

@BBergquist So the issue is with the setting descriptions. Let me remove the quotes from the recommended values as they were not intended to part of the value.

I'm still receiving this same error when I tried setting the sdkPath and the sdkVersion on v1.25.1-beta.

@estellise-yukihime What values are you using?

@JoeRobich These are my values in vscode settings.json:

{
  "omnisharp.sdkVersion": "6.0.401",
  "omnisharp.sdkPath": "/usr/local/share/dotnet/sdk/6.0.401/"
}

This is the omnisharp log:

[fail]: OmniSharp.MSBuild.Discovery.Providers.SdkInstanceProvider
        The Sdk version specified in the OmniSharp settings was not a valid semantic version. Configured version is ''6.0.401''. Please update your settings and restart OmniSharp.
[fail]: OmniSharp.MSBuild.Discovery.Providers.SdkOverrideInstanceProvider
        The Sdk path specified in the OmniSharp settings does not exist. Configured path is ''/usr/local/share/dotnet/sdk/6.0.401/''. Please update your settings and restart OmniSharp.

Is it because the VSCode extension adds the quotes here:
https://github.com/OmniSharp/omnisharp-vscode/blob/55bc0546da2a3b233133d1dca3eee2e1e964f59f/src/omnisharp/server.ts#L403
Which other options don't have.

That fixed it for me, if I edit /Users/user/.vscode/extensions/ms-dotnettools.csharp-1.25.0-darwin-arm64/dist/extension.js to remove those quotes it now works.

Please reopen the issue, it is not solved.

[fail]: OmniSharp.MSBuild.Discovery.Providers.SdkInstanceProvider
        The Sdk version specified in the OmniSharp settings was not a valid semantic version. Configured version is ''6.0.403''. Please update your settings and restart OmniSharp.
[fail]: OmniSharp.MSBuild.Discovery.Providers.SdkOverrideInstanceProvider
        The Sdk path specified in the OmniSharp settings does not exist. Configured path is ''C:/Program Files/dotnet/sdk/6.0.403''. Please update your settings and restart OmniSharp.
"omnisharp.sdkPath": "C:/Program Files/dotnet/sdk/6.0.403",
"omnisharp.sdkVersion": "6.0.403",

Omnisharp version v1.25.2