Visual Studio Code C#“无需调试即可运行"错误 [英] Visual Studio Code C# "Run Without Debugging" error

查看:42
本文介绍了Visual Studio Code C#“无需调试即可运行"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Ubuntu 18.04 上安装了 Visual Studio Code 1.56.2 来开发 Python.

I have Visual Studio Code 1.56.2 installed on Ubuntu 18.04 to develop Python.

几天前,我安装了.NET Core for C# 在 Linux 上编码";所以我可以用 Visual Studio Code 编写 C#.

A few days ago I have installed ".NET Core for C# coding on Linux" so I can code C# with Visual Studio Code.

当我尝试运行Program.cs"时(hello world) app 我收到一个弹出窗口,错误为您没有用于调试 C# 的扩展.我们应该在 Marketplace 中找到 C# 扩展吗?"

When I try to run the "Program.cs" (hello world) app I get a pop up window with error "You don't have an extension for debugging C#. Should we find a C# extension in the Marketplace?"

我已经为 Visual Studio Code 安装了C#"(由 OmniSharp 提供支持).微软"如图所示:

I already have installed "C# for Visual Studio Code (powered by OmniSharp). Microsoft" as shown here:

这是我的工作区结构:

如果您能帮助我解决此问题,我将不胜感激.

I would appreciate any help in resolving this.

推荐答案

确保在名为 的文件夹中同时拥有 launch.jsontask.json.vscode,在您的项目/解决方案根目录中.

Make sure you have both launch.json and task.json in a folder named .vscode, in your project/solution root directory.

如果你不这样做,你可以去菜单Run >添加配置...

If you don-t, you can go to the menu Run > Add Configuration...

它应该自动创建文件,但如果你不能,这里是这些文件内容的示例(你需要调整到你的本地文件/项目/版本值)

It should create the files automatically, but if you can't, here is a sample of what is the content of those files (you'd need to adjust to your local fylesistem/project/version values)

tasks.json:

tasks.json:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "dotnet",
            "type": "shell",
            "args": [
                "build",
                // Ask dotnet build to generate full paths for file names.
                "/property:GenerateFullPaths=true",
                // Do not generate summary otherwise it leads to duplicate errors in Problems panel
                "/consoleloggerparameters:NoSummary"
            ],
            "group": "build",
            "presentation": {
                "reveal": "silent"
            },
            "problemMatcher": "$msCompile"
        }
    ]
}

launch.json

launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": ".NET Core Launch (console)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/bin/Debug/net5.0/net.dll",
            "args": [],
            "cwd": "${workspaceFolder}",
            "console": "internalConsole",
            "stopAtEntry": false
        },
        {
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach",
            "processId": "${command:pickProcess}"
        }
    ]
}

这篇关于Visual Studio Code C#“无需调试即可运行"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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