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"
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.
This is in the docs under debugger-launchjson.md > launchSettings.json support:
"launchSettingsFilePath": "${workspaceFolder}/<Relative-Path-To-Project-Directory/Properties/launchSettings.json"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With