[英]Setting up F# Debugging in VS Code on Linux
I'm new to .NET and F#, and I'm trying to set up F# debugging in VS Code on Linux (NixOS to be precise, although I guess that shouldn't matter). 构建预启动任务有效,但运行应用程序不起作用,没有任何错误 output。
这是重现它的方法。
在名为 test 的目录中,我通过运行 dotnet new console -lang F# 创建了一个 F# 控制台应用程序。 这给了我一个包含以下内容的 Program.fs:
// Learn more about F# at http://docs.microsoft.com/dotnet/fsharp
open System
// Define a function to construct a message to print
let from whom =
sprintf "from %s" whom
[<EntryPoint>]
let main argv =
let message = from "F#" // Call the function
printfn "Hello world %s" message
0 // return an integer exit code
以及包含以下内容的 test.fsproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
</Project>
我创建了一个(特定于 VS 代码的)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/test.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": true,
"console": "internalConsole"
}
]
和一个(VS Code-specific)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": "always"
},
"problemMatcher": "$msCompile"
}
]
当我按 F5 时,它会构建,但应用程序似乎没有运行。 我在调试控制台和集成终端中都没有看到来自 F# 的预期 output Hello world。 尽管"stopAtEntry": true
在 launch.json 中设置了断点,但它不会在任何地方停止,它似乎只是在没有任何 output 的情况下运行。 指定的"program": "${workspaceFolder}/bin/Debug/net5.0/test.dll"
存在,它是在预启动构建中构建的。 实际上,我可以在那里输入任何无意义的路径并看到相同的行为(没有错误输出)。
我究竟做错了什么?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.