我是 C# 新手,正在学习使用复数
我完全遵循了教程正在做的事情,但遇到了教程没有的问题。
当您通过 .Net 编写 C# 代码时,我构建了简单的“Hello World”程序
在Visual Studio Code中,如果选择Start Debugging或Start without Debugging,会弹出如下错误
''找不到任务 'build'"
然后我还是点击调试然后出现以下错误
launch:program dir \ < insert-project-name-here >.dll不存在有打开launch.json的选项
令人困惑的是,.dll 文件确实存在......
此外,检查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",
"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": ["link"],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
Run Code Online (Sandbox Code Playgroud)
Jam*_*lor 13
在 VS Code 中,加载代码库后。调出命令托盘并回车,> .NET Generate Assets for Build and Debug然后按回车/回车。
这将强制 VS Code 重新创建launch.json和task.json文件。
留意 VS Code 窗口的左下角是否有一条吐司消息,如下所示:
并确保您单击 Yes
您需要更改task.json文件中当前读取的行:
"program": "${workspaceFolder}/bin/Debug/<insert-target-framework-here>/<insert-project-name-here>.dll",
Run Code Online (Sandbox Code Playgroud)
替换<insert-target-framework-here>为 csproj 中的目标框架名称,它可能类似于以下内容:
<TargetFramework>netcoreapp2.1</TargetFramework>
Run Code Online (Sandbox Code Playgroud)
您还需要将<insert-project-name-here>.dll字符串替换为生成的 DLL 的名称。
| 归档时间: |
|
| 查看次数: |
11442 次 |
| 最近记录: |