Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is launchSettings.json used when running ASP.NET 5 apps from the command line on Mac?

I am developing an ASP.NET 5 Web API app using Visual Studio code on Mac. I manually modified my Properties/launchSettings.json file to set environment to Staging for all profiles using ASPNET_ENV environment variable: enter image description here

However, when I run dnx web in Mac terminal to start the app, I still get Production environment: enter image description here

Can I use launchSettings.json to specify environment variables (and, thus, environment types) if I use Visual Studio Code on Mac? Or is it specific to full Visual Studio?

ASP.NET 5 docs suggest that launchSettings.json can be used to inject environment variables. However, this SO discussion suggests passing them through commands.

like image 507
Nikolai Samteladze Avatar asked Jan 01 '16 02:01

Nikolai Samteladze


People also ask

What is launchSettings JSON used for?

The launchSettings. json file is used to store the configuration information, which describes how to start the ASP.NET Core application, using Visual Studio. The file is used only during the development of the application using Visual Studio. It contains only those settings that required to run the application.

Is launchSettings JSON used in production?

No, it's not used in production.

Where is the launchSettings JSON?

json launchSettings. json, which is placed in the Properties folder of a project, describes how the application can be launched — the command to execute, whether the browser should be opened, which environment variables should be set, and so on.


1 Answers

LaunchSettings.json is strictly a VS concept. In other cases, you will have to configure environment variables as commands below:

For standard command line run, use:

set ASPNET_ENV=Development

dnx web

For powershell, use:

$env:ASPNET_ENV='Development'

dnx web

Shorter version: dnx web ASPNET_ENV=Development

like image 198
Chrysalis Avatar answered Oct 04 '22 00:10

Chrysalis