Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can vscode use a profile from Properties/launchSettings.json?

Is there a way to just point ".vscode/launch.json" to a profile defined in my "Properties/launchSettings.json" so I don't need to duplicate those values?

I need to support several different editors and also run from command line with

dotnet run --launch-profile="myprofile"
like image 818
red888 Avatar asked Dec 17 '25 04:12

red888


2 Answers

Here is the full example. Let's assume this is your project's structure:

\.vscode
  launch.json
\src
  \YourApp
    \Properties
      launchSettings.json
    appsettings.json    
    YourApp.csproj

Part of launchSettings.json content with profile:

{  
  "profiles": {
    "Sample": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "applicationUrl": "https://localhost:7152;http://localhost:5105",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

The minimum working launch.json file content:

{
    "version": "0.2.0",
    "configurations": [        
        {
            "name": "YourApp Sample",
            "type": "coreclr",
            "request": "launch",
            "program": "${workspaceFolder}/src/YourApp/bin/Debug/net8.0/YourApp.dll",
            "cwd": "${workspaceFolder}/src/YourApp",
            "launchSettingsFilePath": "${workspaceFolder}/src/YourApp/Properties/launchSettings.json",
            "launchSettingsProfile": "Sample"
        }
    ]
}

It's important to set cwd in case if your project folder is not the same as ${workspaceFolder}. More details here.

like image 128
valchetski Avatar answered Dec 19 '25 17:12

valchetski


This is in the docs under debugger-launchjson.md > launchSettings.json support:

"launchSettingsFilePath": "${workspaceFolder}/<Relative-Path-To-Project-Directory/Properties/launchSettings.json"
like image 30
red888 Avatar answered Dec 19 '25 17:12

red888



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!