New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for launchSettings.json to dotnet run #6617

Closed
danroth27 opened this Issue May 17, 2017 · 11 comments

Comments

Projects
None yet
9 participants
@danroth27
Member

danroth27 commented May 17, 2017

@livarcocc @DamianEdwards @sayedihashimi @mlorbetske @richlander lander

For ASP.NET Core projects we setup a bunch of useful machinery in our templates when running in Development. Unfortunately none of this machinery gets used when doing dotnet new and dotnet run because the default environment is assumed to be Production and nothing specifies that the environment should be Development. The environment is typically specified using an environment variable (ASPNETCORE_ENVIRONMENT).

VS today uses launchSettings.json to drive the F5 experience. This file enables you to specify things like environment variables when the application is launched. You can also specify additional command-line args, and whether the browser should be launched and at what address.

We'd like to add support to dotnet run for honoring the settings in launchSettings.json. Initially we can limit this support to the "Project" command name and specifically add support for setting environement variables and command-line args. Later we can look adding support for things like specifying the application URL and launching the browser:

{
  "profiles": {
    "MyAspNetCoreProject": {
      "commandName": "Project",
      "commandLineArgs": "--name value",
      "launchBrowser": true,
      "launchUrl": "https://localhost:44316/",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "https://localhost:44316/"
    }
  }
}

@DustinCampbell We should also chat about having VSCode support this format

@danroth27 danroth27 added this to the 2.0.0 milestone May 17, 2017

@livarcocc

This comment has been minimized.

Show comment
Hide comment
@livarcocc

livarcocc May 18, 2017

Member

@mlorbetske We need the parser for the file. Let me know when you have that.

Member

livarcocc commented May 18, 2017

@mlorbetske We need the parser for the file. Let me know when you have that.

@mlorbetske

This comment has been minimized.

Show comment
Hide comment
@mlorbetske
Member

mlorbetske commented May 18, 2017

@bricelam

This comment has been minimized.

Show comment
Hide comment
@bricelam

bricelam May 23, 2017

Contributor

👀 dotnet-ef wants to use this too. We hope the feature can light up during dotnet exec since that's how we dispatch to the dependency tool which loads the project's assembly and executes Program.BuildWebHost.

Contributor

bricelam commented May 23, 2017

👀 dotnet-ef wants to use this too. We hope the feature can light up during dotnet exec since that's how we dispatch to the dependency tool which loads the project's assembly and executes Program.BuildWebHost.

@livarcocc

This comment has been minimized.

Show comment
Hide comment
@livarcocc

livarcocc May 23, 2017

Member

The scope for now is to just set some environment variables before invoking the app.

Member

livarcocc commented May 23, 2017

The scope for now is to just set some environment variables before invoking the app.

@guidobouman

This comment has been minimized.

Show comment
Hide comment
@guidobouman

guidobouman May 29, 2017

Passing the launchUrl wouldn't be too much work, right?

We have a project with 4 simultaneously running processes that all talk to each other in one way or another. For VS studio users on Windows this all runs smoothly. For VS code on mac we've duplicated the settings to launch.json & tasks.json. But running 4 concurrent processes in VS code crashes on launch. So we run 3 of the 4 processes in the terminal with the CLI. This gets troublesome when we need to specify the server url for each command: --server.urls http://localhost: 44316/. Mapping them from the launchUrl prop would be great.

PS: VS for mac is terribly slow, so we're not using that. Running in there kinda worked, but at the cost of waiting over 3 minutes to start the project.

guidobouman commented May 29, 2017

Passing the launchUrl wouldn't be too much work, right?

We have a project with 4 simultaneously running processes that all talk to each other in one way or another. For VS studio users on Windows this all runs smoothly. For VS code on mac we've duplicated the settings to launch.json & tasks.json. But running 4 concurrent processes in VS code crashes on launch. So we run 3 of the 4 processes in the terminal with the CLI. This gets troublesome when we need to specify the server url for each command: --server.urls http://localhost: 44316/. Mapping them from the launchUrl prop would be great.

PS: VS for mac is terribly slow, so we're not using that. Running in there kinda worked, but at the cost of waiting over 3 minutes to start the project.

@geirsagberg

This comment has been minimized.

Show comment
Hide comment
@geirsagberg

geirsagberg Jul 7, 2017

A problem I ran into is that environment variables from launchSettings.json will always override env.vars set on command line, e.g. I have "ASPNETCORE_ENVIRONMENT": "Development" in launchSettings.json, and then when I run set ASPNETCORE_ENVIRONMENT=Production && dotnet run, the environment is still development.

Maybe there should be a way to opt out of launchSettings?

geirsagberg commented Jul 7, 2017

A problem I ran into is that environment variables from launchSettings.json will always override env.vars set on command line, e.g. I have "ASPNETCORE_ENVIRONMENT": "Development" in launchSettings.json, and then when I run set ASPNETCORE_ENVIRONMENT=Production && dotnet run, the environment is still development.

Maybe there should be a way to opt out of launchSettings?

@geirsagberg

This comment has been minimized.

Show comment
Hide comment
@geirsagberg

geirsagberg Jul 7, 2017

After running dotnet run --help, I noticed the switch --no-launch-profile, which does exactly what I need, so ignore my last comment :)

geirsagberg commented Jul 7, 2017

After running dotnet run --help, I noticed the switch --no-launch-profile, which does exactly what I need, so ignore my last comment :)

@adzhiljano

This comment has been minimized.

Show comment
Hide comment
@adzhiljano

adzhiljano Nov 28, 2017

Sorry for bringing this up, but I noticed this comment: https://github.com/dotnet/cli/blob/master/src/dotnet/commands/dotnet-run/LaunchSettings/ProjectLaunchSettingsProvider.cs#L18
Are you going to support everything from launchSettings.json, since this PR is closed?
I wanted a browser to open when running dotnet run, but nothing happens right now, and i have "launchBrowser": true.
Thanks!

adzhiljano commented Nov 28, 2017

Sorry for bringing this up, but I noticed this comment: https://github.com/dotnet/cli/blob/master/src/dotnet/commands/dotnet-run/LaunchSettings/ProjectLaunchSettingsProvider.cs#L18
Are you going to support everything from launchSettings.json, since this PR is closed?
I wanted a browser to open when running dotnet run, but nothing happens right now, and i have "launchBrowser": true.
Thanks!

@livarcocc

This comment has been minimized.

Show comment
Hide comment
@livarcocc

livarcocc Nov 28, 2017

Member

We haven't talked about extending the support for launchSettings.json beyond what we already have. And we don't have plans to support 100% of it, as there are things there that don't make sense in the command line.

Member

livarcocc commented Nov 28, 2017

We haven't talked about extending the support for launchSettings.json beyond what we already have. And we don't have plans to support 100% of it, as there are things there that don't make sense in the command line.

@LordMike

This comment has been minimized.

Show comment
Hide comment
@LordMike

LordMike Dec 17, 2017

Added note on Docs page to document this new default.

https://docs.microsoft.com/en-us/aspnet/core/fundamentals/environments

EDIT: probably have a higher chance of success here: aspnet/Docs#5023

LordMike commented Dec 17, 2017

Added note on Docs page to document this new default.

https://docs.microsoft.com/en-us/aspnet/core/fundamentals/environments

EDIT: probably have a higher chance of success here: aspnet/Docs#5023

@matsennin

This comment has been minimized.

Show comment
Hide comment
@matsennin

matsennin Jul 29, 2018

thanks @geirsagberg, i was having the same problem with my app!

matsennin commented Jul 29, 2018

thanks @geirsagberg, i was having the same problem with my app!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment