【发布时间】:2019-10-06 12:55:47
【问题描述】:
我是 DotnetCore 和 MS 编程的新手。随着 MS 对平台中立性的新推动,我有兴趣尝试一下,看看它是否按承诺的方式工作。也就是说,我什至在 VSCode 上的 Windows 上的 DotNetCore 上运行 helloworld 程序时遇到了问题。在我的命令提示符和 VisualStudio 2019(我的 mac 的 VS Studio for mac)上似乎一切正常。真正的压力似乎在 Windows 10 中的 VSCode 上。如果可以的话,我将不胜感激
我收到的错误是“找不到 coreclr 类型的调试适配器”。无论我做什么,我都会遇到这个错误。 1.安装Dotnet core 3.0 2. 设置指向 C:\Program Files\dotnet\sdk\3.0.100\Sdks 的 MSBuildSDKsPath 环境变量 3.多次重启机器
没有任何作用。这是示例代码以及我的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}");
}
}
}
这是我的 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}"
}
]
}
当我从命令提示符执行 dotnet build 和 dotnet run 时,一切都很好
dotnet 构建:
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 运行:
PS C:\Users\Krishnan\Projects\DotNet\OOPExample> dotnet run
Hello World - 18.027756377319946
如果您想知道我是如何创建这个项目的,那只不过是一个简单的 dotnet 新控制台命令。所以没什么特别的
【问题讨论】:
-
VSCode C# 扩展需要从 Internet 下载几个位,并且似乎在这台机器上这些下载失败。
-
你安装了omnisharp吗?
-
这是推荐的扩展“C# for Visual Studio Code(由 OmniSharp 提供支持)”,我安装了它。顺便说一句,正如我所说,我对 Ubuntu 或 Mac 没有任何问题,这个问题只在 Windows 10 上
-
@LexLi 我知道有些下载失败了。问题是它是哪一个以及如何解决它。
-
github.com/OmniSharp/omnisharp-vscode/wiki/… 你可能会从那里得到一些想法。
标签: c# .net-core visual-studio-code vscode-debugger