繁体   English   中英

Visual Studio 代码未运行默认 C# 控制台应用程序

[英]Visual Studio Code Not Running Default C# Console App

因此,使用do.net new console -o app构建的默认程序不会在 Visual Studio Code 中运行。

安装了 .NET SDK 和 C# 分机。

当我尝试为其添加配置时,我得到了这个乱码。

{
    // 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",
            "WARNING01": "*********************************************************************************",
            "WARNING02": "The C# extension was unable to automatically decode projects in the current",
            "WARNING03": "workspace to create a runnable launch.json file. A template launch.json file has",
            "WARNING04": "been created as a placeholder.",
            "WARNING05": "",
            "WARNING06": "If OmniSharp is currently unable to load your project, you can attempt to resolve",
            "WARNING07": "this by restoring any missing project dependencies (example: run 'dotnet restore')",
            "WARNING08": "and by fixing any reported errors from building the projects in your workspace.",
            "WARNING09": "If this allows OmniSharp to now load your project then --",
            "WARNING10": "  * Delete this file",
            "WARNING11": "  * Open the Visual Studio Code command palette (View->Command Palette)",
            "WARNING12": "  * run the command: '.NET: Generate Assets for Build and Debug'.",
            "WARNING13": "",
            "WARNING14": "If your project requires a more complex launch configuration, you may wish to delete",
            "WARNING15": "this configuration and pick a different template using the 'Add Configuration...'",
            "WARNING16": "button at the bottom of this file.",
            "WARNING17": "*********************************************************************************",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/bin/Debug/<insert-target-framework-here>/<insert-project-name-here>.dll",
            "args": [],
            "cwd": "${workspaceFolder}",
            "console": "internalConsole",
            "stopAtEntry": false
        },
        {
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach"
        }
    ]
}

请记住,这是一个默认的应用程序,由程序本身构建,我没有做任何更改。

它应该只打印“Hello World”。 到控制台。

如果我尝试从终端运行,我得到这个“找不到要运行的项目。确保项目存在于...”,当我尝试从菜单栏运行时,我得到“找不到任务'建造'。”

如果我尝试强制执行它,它会说它执行时出错,如果我单击显示错误,我会得到非常有用的“工作区中未检测到任何问题”。

您究竟如何在 VSCode 中构建 C# 控制台应用程序,因为它显然不是按照 Microsoft 自己的网站步骤进行的。

这是因为这一行:

${workspaceFolder}/bin/Debug/insert-target-framework-here/insert-project-name-here.dll”

您应该使用已安装的框架和内置的 DLL 名称而不是这些名称:insert-target-framework-here insert-project-name-here.dll

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM