debugging 调试时的VSCodeAsp.Net核心命令行参数?

2hh7jdfx  于 2023-10-24  发布在  Vscode
关注(0)|答案(1)|浏览(160)

刚刚阅读了斯科特艾伦的this文章。
将命令行参数指定给.net核心的方法似乎很有趣,但是当我们运行调试器时,我们如何从VS Code传递这些参数(如果安装了launch.json,通常使用F5命令)?
例如dotnet run dropdb migratedb seeddb

vawmfj5a

vawmfj5a1#

  • 从评论中删除答案 *
    注意launch.json在您项目下的.vscode文件夹中。

launch.json中,尝试添加:

"args": ["dropdb", "migratedb", "seeddb"]

到目标发射位置

在launch.json中提供上下文

默认情况下,launch.json将包含一个空的args元素,看起来像这样:

{
    // 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 (web)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/<YourProjName>/bin/Debug/net6.0/YourProjName.dll",
            "args": [],
            "cwd": "${workspaceFolder}/<YourProjName>",
            "stopAtEntry": false,
            "serverReadyAction": {
            .
            .
            .
            // launch.json file continues...

相关问题