[英]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.