gpt4 book ai didi

c# - Visual Studio Code 编译错误 - 必须配置 launch.json

转载 作者:太空狗 更新时间:2023-10-29 17:40:02 26 4
gpt4 key购买 nike

我正在尝试使用 Visual Studio 代码在 Windows 7 上编译 C# 代码。我已下载所有扩展,但出现此错误:

launch: program 'launch: launch.json must be configured. Change 'program' to the path to the executable file that you would like to debug.

我不知道如何修复它。这是我认为需要在 launch.json 文件中更改的行,这是当前存在的行:

"program": "${workspaceRoot}/bin/Debug/netcoreapp1.0/exam 1.dll"

(考试 1,因为这是包含我的 C# 代码的 .cs 文件的名称)

当我进入我的 .cs 文件所在的文件夹时,这是整个路径:

  • “C:\Users\Kdrumz\Desktop\ObjectOriented\exam 1.cs”。

我很困惑。另外,在使用 visual studio code 时我是否总是需要这样做?非常感谢任何帮助!

使用 visual studio code 1.7.1 版本

最佳答案

我通过像这样替换 launch.json 中所有“<>”样式的值来修复它(在我的例子中,项目名为“sample01”):

{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/bin/Debug/netcoreapp1.0/sample01.dll",
"args": [],
"cwd": "${workspaceRoot}",
"stopAtEntry": false,
"externalConsole": false
}
}
}

如您所见,我只使用了 1 个名为“.NET Core Launch(控制台)”的配置。这个名称可以更改,当您单击最左侧的调试菜单(带有错误符号的菜单)并查看最顶部时,您会看到它。

现在我输入了我的构建配置的完整路径(在我的示例中是 .NET Core 1.0)并且它可以工作。

所以是的,如果它预先配置了“<>”元素,您将不得不手动完成。如果您使用 dotnet new 然后使用 code . 来启动新项目,较新版本的 Visual Studio Code 将创建可立即运行的 launch.json现在。

关于c# - Visual Studio Code 编译错误 - 必须配置 launch.json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40793060/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com