liveBook · Manning

launchSettings.json

As explained in Building Web APIs with ASP.NET Core

launchSettings.json is an ASP.NET Core configuration file that defines local development launch profiles, server settings, URLs, and environment variables.

launchSettings.json is the local launch configuration for an ASP.NET Core project. Stored in /Properties/, it controls how the board-game API starts during development; it is not deployed to production. section 2.4.1 section 2.4

The file organizes launch behavior around three main areas:

  • $schema identifies the JSON schema used to describe the file. section 2.4.1
  • iisSettings provides base settings for IIS Express, including local HTTP and HTTPS ports. section 2.4.1
  • profiles defines selectable launch configurations such as IIS Express and the MyBGList Kestrel profile. section 2.4.1
  • A profile can select the command, browser launch behavior, starting URL, application URLs, and ASPNETCORE_ENVIRONMENT value. section 2.4.1 section 2.5.1

Prepare a tester profile

For the board-game API, configure the Kestrel profile to use TCP port 55221 for HTTP and 55222 for HTTPS, set ASPNETCORE_ENVIRONMENT to Staging, and open the BoardGamesController.Get() route when the application starts. Leave IIS Express unchanged when testers will not use it. section 2.5.1

Listing 2.1 Modified launchSettings.json file
{
  "$schema": "https://json.schemastore.org/launchsettings.json",
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:40080",                         #1
      "sslPort": 40443                                                    #1
    }
  },
  "profiles": {
    "MyBGList": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "launchUrl": "swagger",                                             #2
      "applicationUrl": "https://localhost:40443;http://localhost:40080", #3
      "environmentVariables": {                                           #4
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "swagger",                                             #5
      "environmentVariables": {                                           #6
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

Use the modified launchSettings.json listing to inspect a complete profile with HTTPS and HTTP application URLs, automatic browser launch, a Swagger starting URL, and a Development environment variable. section 2.4.1

Choose a profile from Visual Studio’s Start control, then run the application and verify that the selected ports and starting endpoint behave as configured. The environment value also affects middleware: Development enables the developer exception page, while changing the environment can exercise production-style exception handling. section 2.4.1 section 2.4.3

How Building Web APIs with ASP.NET Core covers it

How deep it goes
Defines file sections and practical profile changes, but stops short of production deployment configuration.
Examples
Uses MyBGList profiles, localhost ports, Swagger, staging testers, and the BoardGamesController.Get() endpoint.
What it assumes
Assumes a generated ASP.NET Core web API project and basic Visual Studio familiarity.
What you can do after
Operate local ASP.NET Core launches with selected servers, ports, startup routes, browsers, and runtime environments.
How it connects
Connects ASP.NET Core launch profiles with Kestrel, IIS Express, Visual Studio, environment variables, and middleware.

Also explained in

Compare how 4 books explain launchSettings.json →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Web APIs with ASP.NET Core. The section links point to the parts of the book it draws on.