Nexus23 Nexus23 - 1 year ago 552
ASP.NET (C#) Question

dotnet run OR dotnet watch with development environment from command line?

I am using

dotnet watch
command to run core project. However by default it is picking up the
as environment.

I have tried both options using:

1) dotnet watch ASPNETCORE_ENVIRONMENT=Development

2) dotnet run ASPNETCORE_ENVIRONMENT=Development

But it still picks up production as environment.

Note: In visual studio environment variable is set in project properties as Development by default and running from visual studio picks that variable.

Question is: How to run dotnet core project in development from command line using either?:

1) dotnet run
2) dotnet watch

Answer Source

ASPNETCORE_ENVIRONMENT is an environment variable (and AFAIK) not a switch to the dotnet cli.

So what you would do is set it prior to using the tool:

rem Windows
C:\> dotnet ...

rem Unix
$ dotnet ...
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download