ひでぼ~blog

C#ときどきゲーム

VSCodeのデバッグコンソールでdll読み込みメッセージを非表示にする

VSCodeC#のコンソールアプリをデバッグ実行したとき、dllを読み込むメッセージがたくさん表示されます。

f:id:hideb3:20211130203543p:plain
設定前のデバッグコンソール

アプリから出力したメッセージが埋もれてしまって見にくいので、これを表示しないようにしてみます。 .vscode/launch.jsonの↓の部分にmoduleLoadというプロパティを追加し、値をfalseにします。

{
    "version": "0.2.0",
    "configurations": [
        {
            // Use IntelliSense to find out which attributes exist for C# debugging
            // Use hover for the description of the existing attributes
            // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
            "name": ".NET Core Launch (console)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            // If you have changed target frameworks, make sure to update the program path.
            "program": "${workspaceFolder}/bin/Debug/net6.0/ConsoleApp.dll",
            "args": [],
            "cwd": "${workspaceFolder}",
            // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
            "console": "internalConsole",
            "stopAtEntry": false,
            // これを追加
            "logging": {
                "moduleLoad": false
            }
        },
        {
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach"
        }
    ]
}

これで実行するとデバッグコンソールがかなり見やすくなります。

f:id:hideb3:20211130203407p:plain
設定後のデバッグコンソール

参考

stackoverflow.com