List of configurable options
AI agents: See llms.txt for documentation discovery and navigation. Documentation articles are also available as Markdown by appending .md to the article URL. Join VS Code at Microsoft Ignite or catch the sessions online. A year of VS Code, wrapped. Explore the highlights. Configuring C# debugging View as Markdown Ask in VS Code Ask in VS Code Insiders You can configure the C# debugger in Visual Studio Code with a launch.json , launchSettings.json , or your user settings.json file.
Walkthrough: setting command-line arguments Before we get into the details of all the possible options, let's walk through a basic scenario: setting command-line arguments to your program. These steps also work for updating other basic options like environment variables or the current working directory. Approach 1: launchSettings.json For C# Dev Kit, the recommended way to debug is to let C# Dev Kit automatically figure out how to debug from settings in the project file.
This means that you either don't have a <workspace_root>/.vscode/launch.json file, or if you have one, you have "type": "dotnet" set for the active configuration. For command-line arguments, "figure out from the project file" means to pull the value from <Project-Directory>/Properties/launchSettings.json . The advantage of launchSettings.json is that it allows settings to be shared between Visual Studio Code, full Visual Studio, and dotnet run .
For this case, here are the steps to set the command-line arguments: In workspace Explorer view, navigate to the directory of the project (.csproj file) you want to launch If there isn't a Properties directory already, create it If there isn't a launchSettings.json file already, create one, you can use the below text as an example Change the commandLineArgs property to what you would like the command-line arguments to be Example launchSettings.json file : { "profiles" : { "MyLaunchProfileName" : { "commandName" : "Project" , "commandLineArgs" : "MyFirstArgument MySecondArgument" } } } Approach 2: launch.json If you are using the coreclr or clr debug adapter type in VS Code, command-line arguments are stored in your <workspace_root>/.vscode/launch.json .
To edit them in this case: Open up <workspace_root>/.vscode/launch.json Find the coreclr or clr launch configuration you want to launch Edit the args property. This can either be a string, or an array of strings Configuring launchSettings.json With C# Dev Kit, you can bring your launchSettings.json from Visual Studio to work with Visual Studio Code Example: { "iisSettings" : { "windowsAuthentication" : false , "anonymousAuthentication" : true , "iisExpress" : { "applicationUrl" : "http://localhost:59481" , "sslPort" : 44308 } }, "profiles" : { "EnvironmentsSample" : { "commandName" : "Project" , "dotnetRunMessages" : true , "launchBrowser" : true , "applicationUrl" : "https://localhost:7152;http://localhost:5105" , "environmentVariables" : { "ASPNETCORE_ENVIRONMENT" : "Development" } }, "EnvironmentsSample-Staging" : { "commandName" : "Project" , "dotnetRunMessages" : true , "launchBrowser" : true , "applicationUrl" : "https://localhost:7152;http://localhost:5105" , "environmentVariables" : { "ASPNETCORE_ENVIRONMENT" : "Staging" , "ASPNETCORE_DETAILEDERRORS" : "1" , "ASPNETCORE_SHUTDOWNTIMEOUTSECONDS" : "3" } }, "EnvironmentsSample-Production" : { "commandName" : "Project" , "dotnetRunMessages" : true , "launchBrowser" : true , "applicationUrl" : "https://localhost:7152;http://localhost:5105" , "environmentVariables" : { "ASPNETCORE_ENVIRONMENT" : "Production" } }, "IIS Express" : { "commandName" : "IISExpress" , "launchBrowser" : true , "environmentVariables" : { "ASPNETCORE_ENVIRONMENT" : "Development" } } } } Profile properties commandLineArgs - The arguments to pass to the target being run. executablePath - An absolute or relative path to the executable. workingDirectory - Sets the working directory of the command. launchBrowser - Set to true if the browser should be launched. applicationUrl - A semi-colon delimited list of URL(s) to configure for the web server. sslPort - The SSL port to use for the web site. httpPort - The HTTP port to use for the web site.
List of configurable options Below are common options you may want to change while debugging. PreLaunchTask The preLaunchTask field runs the associated taskName in tasks.json before debugging your program. You can get the default build prelaunch task by executing the command Tasks: Configure Tasks Runner from the VS Code Command Palette. This creates a task that runs dotnet build . You can read more in the VS Code Tasks documentation.
Availability launch.json ✔️ settings.json ❌ launchSettings.json ❌ Program The program field is set to the path of the application dll or .NET Core host executable to launch. This property normally takes the form: "${workspaceFolder}/bin/Debug/<target-framework>/<project-name.dll>". Example: "${workspaceFolder}/bin/Debug/netcoreapp1.1/MyProject.dll" Where: <target-framework> is the framework that the debugged project is being built for.
This is normally found in the project file as the 'TargetFramework' property. <project-name.dll> is the name of debugged project's build output dll. This is normally the same as the project file name but with a '.dll' extension. Availability launch.json ✔️ settings.json ❌ launchSettings.json ✔️ as executablePath Cwd The working directory of the target process. Availability launch.json ✔️ settings.json ❌ launchSettings.json ✔️ as workingDirectory Args These are the arguments that will be passed to your program.
Availability launch.json ✔️ settings.json ❌ launchSettings.json ✔️ as commandLineArgs Stop at Entry If you need to stop at the entry point of the target, you can optionally set stopAtEntry to be "true". Availability launch.json ✔️ settings.json ✔️ as csharp.debug.stopAtEntry launchSettings.json ❌ Starting a Web Browser The default launch.json template (as of C# extension v1.20.0) for ASP.NET Core projects uses the following to configure VS Code to launch a web browser when ASP.NET starts: "serverReadyAction" : { "action" : "openExternally" , "pattern" : " \\ bNow listening on: \\ s+(https?:// \\ S+)" } Notes about this: If you do NOT want the browser to automatically start, you can just delete this element (and a launchBrowser element if your launch.json has that instead).
This pattern launches the web browser using the URL that ASP.NET Core writes to the console. If you want to modify the URL see specifying the browser's URL . This may be useful if the target application is running on another machine or container, or if applicationUrl has a special host name (example: "applicationUrl": "http://*:1234/" ). serverReadyAction is a new feature from VS Code. It is recommended over the previous launchBrowser feature that is built into the C# extension's debugger as it can work when the C# extension is running on a remote machine, it uses the default browser configured for VS Code, and it also allows using a script debugger.
You can continue using launchBrowser instead if none of those features are important to you. You also can continue to use launchBrowser if you want to run a specific program instead of starting the default browser. More documentation for serverReadyAction can be found in the Visual Studio Code February 2019 release notes . The way this works is that VS Code scrapes the output that is set to the console. If a line matches the pattern, it launches a browser against the URL that was 'captured' by the pattern.
Here is an explanation of what the pattern does: \\b : Matches on a word boundary. Note that \b indicates a word boundary, but because this is in a json string, the \ needs to be escaped, hence \\b . Now listening on: : This is a string literal, meaning that the next text must be Now listening on: . \\s+ : Matches one or more space characters. ( : This is the beginning of a 'capture group'. This indicates the region of text
The rest of this page is on the live site.