VSCode 中的 DotNet core 3.0 编译问题 [英] DotNet core 3.0 compilation issues in VSCode

查看:37
本文介绍了VSCode 中的 DotNet core 3.0 编译问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 DotnetCore 和 MS 编程的新手.随着 MS 对平台中立性的新推动,我有兴趣尝试一下,看看它是否像它承诺的那样工作.也就是说,我什至在 Windows 上从 VSCode 获得一个 helloworld 程序在 DotNetCore 上工作时遇到了问题.在我的命令提示符和 VisualStudio 2019(我的 mac 的 VS Studio for mac)上,一切似乎都运行良好.真正的压力似乎在 Windows 10 中的 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

我收到的错误是找不到 coreclr 类型的调试适配器".不管我做什么,我最终都会遇到这个错误.1.安装Dotnet core 3.02. 设置指向 C:\Program Files\dotnet\sdk\3.0.100\Sdks 的 MSBuildSDKsPath 环境变量3.多次重启机器

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

没有任何效果.这是示例代码以及我的launch.json.

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}");
        }
    }
}

这是我的launch.json

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}"
        }
    ]
}

当我从命令提示符执行 dotnet build 和 dotnet run 时,一切都很好

When I execute dotnet build and dotnet run from command prompt, everything is fine

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 新控制台命令.所以没什么好看的

If you are wondering how I created this project, it was nothing more than a simple dotnet new console command. So nothing fancy

推荐答案

也许这可以帮助遇到这个问题的人:在过去的一周里我已经解决了两次这个错误.

Maybe this can help someone having this problem: Twice in the past week I have resolved this error.

第一次卸载/重新安装 OmniSharp C# 扩展.

First time by uninstalling/re-installing the OmniSharp C# extension.

第二次将 VSCode 更新到最新版本.

Second time by updating VSCode to latest.

我还没有弄清楚这两件事是否相关,但我在 OmniSharp 或 VSC 发行说明中没有看到任何关于它的具体内容.

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.

这篇关于VSCode 中的 DotNet core 3.0 编译问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆