'DotNet core 3.0 compilation issues in VSCode
I am new to DotnetCore and MS programming. With the new push from MS to be more platform neutral, I had an interest in me to try it out and see if it works the way it promises. That said, I have had problem even getting a helloworld program work on DotNetCore on windows from VSCode. Everything seems to work fine on my command prompt and VisualStudio 2019, my mac's VS Studio for mac. Real strain seems to be on VSCode in Windows 10. I'd appreciate all your help, if you can
The error I receive is "Cannot find debug adapter for type coreclr". No matter what I do, I end up with this error. 1. INstalled Dotnet core 3.0 2. Set up MSBuildSDKsPath env variable that points to C:\Program Files\dotnet\sdk\3.0.100\Sdks 3. Restarted machine as many times
Nothing works. Here's the sample code as well as my launch.json.
using System;
namespace OOPExample
{
public struct Dimensions {
public double Length { get; }
public double Width { get; }
public Dimensions(double length, double width) {
Length = length;
Width= width;
}
public double Diagonal => Math.Sqrt(Length * Length + Width * Width);
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine($"Hello World - {new Dimensions(10.0, 15.0).Diagonal}");
}
}
}
Here's my launch.json
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.0/OOPExample.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
When I execute dotnet build and dotnet run from command prompt, everything is fine
dotnet build:
C:\Users\Krishnan\Projects\DotNet\OOPExample> dotnet build
Microsoft (R) Build Engine version 16.3.0+0f4c62fea for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 12.86 ms for C:\Users\Krishnan\Projects\DotNet\OOPExample\OOPExample.csproj.
OOPExample -> C:\Users\Krishnan\Projects\DotNet\OOPExample\bin\Debug\netcoreapp3.0\OOPExample.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.77
dotnet run:
PS C:\Users\Krishnan\Projects\DotNet\OOPExample> dotnet run
Hello World - 18.027756377319946
If you are wondering how I created this project, it was nothing more than a simple dotnet new console command. So nothing fancy
Solution 1:[1]
Maybe this can help someone having this problem: Twice in the past week I have resolved this error.
First time by uninstalling/re-installing the OmniSharp C# extension.
Second time by updating VSCode to latest.
I haven't figured out if the two things are related, but I don't see anything in OmniSharp or VSC release notes about it specifically.
Solution 2:[2]
first of all, ensure that you had install official Microsoft C# extension for vs-code.
then, if still doesn't run it would be a problem with your launch.json
file.
Solution 3:[3]
The following error message appeared when I tried to start debugging.
"Cannot find debug adapter for type 'coreclr'".
If the following error message was appearing too, like in my case, I'd recommend you to also consider to click on "Developer Tools" because I think there's a very good chance that you would be able to get a good hint there.
"Extension host terminated unexpectedly".
In the box of the above message, I clicked "Developer Tools" and then I could see some error messages containing a string "kite" that made me guess that, in my case, these error messages could've been coming from the extension "kite" that I had installed a long time ago. After disabling this extension and restarting VS Code, neither error message appeared again. (Now I'm not sure if restarting was essential.) I'm not saying that the extension kite is troublesome. In your case, the problem could've been coming from some other extensions or something other than an extension. I'm saying that the "Developer Tools" could be a goldmine of hints.
I've one more piece of happy news. Later on, these error messages didn't appear even after enabling this extension "kite". I could start debugging without giving up this extension.
Solution 4:[4]
I was getting OPs error message, but only when using Run & Debug with ".NET Core Launch (web)" configuration in a Dev Container:
Couldn't find a debug adapter descriptor for debug type 'coreclr' (extension might have failed to activate)
I noticed in VS Code's Output tab, on the C# console, the following additional output:
Installing C# dependencies...
Platform: linux, x86_64, name=ubuntu, version=20.04
Downloading package 'OmniSharp for Linux (x64)'
Retrying from 'https://roslynomnisharp.blob.core.windows.net/releases/1.37.8/omnisharp-linux-x64-1.37.8.zip'
Failed at stage: downloadPackage
Error: Failed to establish a socket connection to proxies: ["PROXY 127.0.0.1:8118"]
It seems that the Dev Container picks up the HTTP_PROXY
and HTTPS_PROXY
environment variables from the host but, being a guest container, its 127.0.0.1 address is different than the host computer's 127.0.0.1 address.
I fixed this by way of Windows-Pause > Advanced System Settings > Advanced > Environment Variables... > with the host computer's "public" IP address as returned from ipconfig /all
, e.g.:
- HTTP_PROXY = http://192.168.0.111:8118/
- HTTPS_PROXY = http://192.168.0.111:8118/
Followed by closing and reopening VS Code, with Run & Debug now working as expected in the Dev Container.
Solution 5:[5]
I had the same problem, I just uninstalled the Omnisharp and all extensions from dotnet, closed the VSCode and after reopened it, and install everything again(package Omnisharp). Now is working as expected.
Just to let registered my SO is Linux Ubuntu 20.04.
Solution 6:[6]
I had my share of this debug error today. The following steps I took to resolve the issue might be helpful to someone.
- Uninstalled "C# for Visual Studio Code (powered by OmniSharp)" and then installed it back.
- Closed Visual Studio Code
- Restarted VS Code
- Launched the debug button
I hope this is helpful!
Solution 7:[7]
I was also getting same error after running dotnet clean
-i simply closed vscode -then open vscode -dotnet restore -dotnet build my error solved
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Paully |
Solution 2 | Ashkan Rahmani |
Solution 3 | |
Solution 4 | AlwaysLearning |
Solution 5 | Jeffmonteiro |
Solution 6 | Peace Bakare |
Solution 7 | akhil |