Skip to content

Conversation

@karolz-ms
Copy link
Member

Resolves #5102

@karolz-ms
Copy link
Member Author

Test configuration:

{
    "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/hellocsharp.dll",
            "args": [],
            "cwd": "${workspaceFolder}",
            // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
            "console": "internalConsole",
            "stopAtEntry": false,
            "envFile": "${input:getPathToFile}"
        },

        {
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach"
        }
    ],

    "inputs": [
        {
            "id": "getPathToFile",
            "description": "Choose environment file",
            "type": "pickString",
            "options": [
                "${workspaceFolder}/richard.env",
                "${workspaceFolder}/john.env"
            ]
        }
    ]
}

Program:

while (true) {
    var ufn = System.Environment.GetEnvironmentVariable("USER_FIRST_NAME");
    if (ufn != null) {
        Console.WriteLine($"Hello, {ufn}! Tell me how you're doing?");
    } else {
        Console.WriteLine("Hello, World! Tell me how you're doing?");
    }
    Thread.Sleep(TimeSpan.FromSeconds(3));
}

Copy link
Contributor

@gregg-miskelly gregg-miskelly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM

@gregg-miskelly
Copy link
Contributor

gregg-miskelly commented Apr 27, 2022

One thing to verify: if you debug multiple times, will VS Code always open the debug console on startup? I want to verify VS Code still respects internalConsoleOptions if it is added this way.

@karolz-ms
Copy link
Member Author

One thing to verify: if you debug multiple times, will VS Code always open the debug console on startup? I want to verify VS Code still respects internalConsoleOptions if it is added this way.

Yes, during my testing VS Code always opens Debug Console when debugging is started, even if I manually close it between debug sessions.

@gregg-miskelly gregg-miskelly enabled auto-merge (squash) April 27, 2022 20:47
@gregg-miskelly gregg-miskelly merged commit 7b1f541 into dotnet:master Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

coreclr debug configuration should support input variables for envFile

2 participants