Using .NET Core launchSettings.json to run/debug apps in Rider
A .NET Core application can have a file called
launchSettings.json, which describes how a project can be launched. It describes the command to run, whether the browser should be opened, which environment variables should be set, and so on. This information can then be used by
dotnet to run or debug our application.
The latest Rider 2018.3 Early Access Preview (EAP) build adds support for generating Rider run/debug configurations from
launchSettings.json. This makes the launch profile portable between the command-line
dotnet tools and Rider. Let’s see how this works!
Generating Rider run configurations based on
When first opening a project that contains one or more
launchSettings.json files, Rider will auto-import the launch profiles defined in it and create run/debug configurations for them.
For example, after cloning and opening the Orchard CMS, we will see the following run configurations in Rider – all originating from the
Rider only generates run/debug configurations automatically when no user-defined run configurations were created before. If that’s the case, we can use the Generate Configurations context menu on a
launchSettings.json file to import the launch profile(s) into Rider. Using the Run project context menu will also pick up these settings.
Tip: when removing all existing run configurations in Rider and re-opening the project,
launchSettings.json files will be imported again as run configurations.
Editing a generated run configuration
Run/debug configurations that are generated from a
launchSettings.json file can be edited. Via the toolbar or the Run | Edit Configurations… menu, we can look at the imported configuration and make some changes to it when needed.
Some options are editable, for example the target framework to use, as well as .NET runtime arguments, while options that come from
launchSettings.json are read-only here.
Rider comes with editor support for
launchSettings.json files as well. There is syntax highlighting and code analysis, and code completion, too.
From the gutter, we can also run or debug a launch profile.
Supported commands and options
Launch profiles in a
launchSettings.json support a number of configuration options. For example, there is the command that will be executed when running it. Right now, Rider supports the
Projectwill always start the current project (ignoring the
executablePathsetting), and supports launching the browser and other options.
Executablewill start the executable defined in the
executablePathsetting, but does not support browser options.
- The IISExpress command is not supported in Rider yet.
We can make use of environment variables, as well as MSBuild variables in many parameters (
- To inject an environment variable, we can use the percent syntax, e.g.
%TEMP%. This syntax should also be used on Mac OS X and Linux, which corresponds to how the
dotnetcommand line tool handles environment variables in
- For MSBuild variables, we can use the
launchSettings.json file, we can also define whether the browser should be started or not. The
launchUrl setting will be opened in the browser when enabled.
applicationUrl setting is added to the
ASPNETCORE_URLS environment variable so that an ASP.NET Core app can bind to that URL. To disable this behavior, a setting
"externalUrlConfiguration": true can be added to the launch profile.
Executable paths defined in
launchSettings.json will be resolved in two ways: relative to the working directory, and using the system
PATH environment variable.
Download Rider 2018.3 EAP and give it a try! We would love to hear your feedback on these updates!
Subscribe to Blog updates
Thanks, we've got you!
Another Look into the Future with Rider’s Predictive Debugger
In the 2023.2 release cycle, we’ve introduced the Predictive Debugger in ReSharper, which gives you predictions about code paths and variables beyond the current execution pointer. We’ve written extensively about its advantages compared to alternative debugging strategies like thorough thinking, log…
Visualize Entity Framework Relationships and Additional Query Analysis in ReSharper 2023.3
A lot of teams are using Entity Framework or EF Core to work with their database. As an Object-Relational Mapper (ORM), it bridges objects in code to a relational database model, so that as a developer you don’t have to worry too much about the actual database. We all know: that’s not entirely tr…
Automatically Analyze ASP.NET Core Performance With Dynamic Program Analysis
Slow web pages may make your users or customers abandon your web application, even before they’ve had a proper look at it. You’ve likely also been frustrated working with a web application that is slow to load. The good news is that the latest versions of ReSharper and JetBrains Rider’s Dynamic P…
OSS Power-Ups: MassTransit – Webinar Recording
The recording of our webinar, OSS Power-Ups: MassTransit, with Chris Patterson, is available. This was the thirteenth episode of our OSS Power-Ups series, where we put a spotlight on open-source .NET projects. Subscribe to our community newsletter to receive notifications about future webinars.…