
I recently came across Visual Studio’s .slnLaunch file. If you work on two machines, it saves you from picking your F5 startup projects twice.
Say your solution has an API and a web front end. You want to set breakpoints in the API and use the site to hit them. One launch profile can start both projects and attach the debugger only to the API.
Share the profile through Git
- In Visual Studio 2022 17.11 or later, open Tools > Options. Under Preview Features, make sure Enable Multi-Project Launch Profiles is checked. The label may vary between versions.
- Right-click the solution and select Configure Startup Projects.
- Choose Multiple startup projects and name the profile API + Web. Set the API to Start and the web project to Start without debugging. The arrows set the launch order, but they don’t guarantee that the API is ready when the site starts.
- Check Share Profile and click OK. Visual Studio writes a JSON file named after the solution, such as
MySolution.slnLaunch, in the same folder. Commit the file to Git and push the commit.
If you leave Share Profile unchecked, the profile is saved to a user-specific file.
Here’s what the shared profile looks like. Visual Studio may also add a DebugTarget key to each project for the debug target you selected.
[
{
"Name": "API + Web",
"Projects": [
{ "Path": "Api\\Api.csproj", "Action": "Start" },
{ "Path": "Web\\Web.csproj", "Action": "StartWithoutDebugging" }
]
}
]
On the other machine, check the preview option too, then pull the commit and open the solution. Select API + Web in the toolbar and press F5. The project paths are relative to the solution, so you can clone the repository into a different folder.
Further reading
- Set multiple startup projects: Microsoft’s documentation covers the profile options and shows where to find them in Visual Studio.
- Multi-Project Launch Configuration: the Visual Studio team’s announcement of the feature, from September 2024.
Happy Coding :)