簡體   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