Ristogod
Ristogod

Reputation: 1005

Set multiple different ASPNETCORE_ENVIRONMENT values for console apps running on same machine

We have multiple environments running from the same machine. For our web applications we can easily set the ASPNETCORE_ENVIRONMENT variable for each different web application using the web.config.

However, we also are deploying console applications that are scheduled to run using Windows Task Scheduler. We haven't been able to figure out how to set per console app a different ASPNETCORE_ENVIRONMENT variable.

We've looked at the Microsoft documentation and it shows using a command line that looks like this:

set ASPNETCORE_ENVIRONMENT=Development

Does that set the whole machine to that environment? We don't understand the scope of running a command like that.

Anyone have any insight to the intended use for setting this variable for a console app?

Upvotes: 1

Views: 945

Answers (1)

Brian Ogden
Brian Ogden

Reputation: 19232

ASPNETCORE_ENVIRONMENT is a machine environment variable, yes it sets the whole machine to that environment.

You have an architectural issue going on here, ASPNETCORE_ENVIRONMENT is not your problem.

Why would a machine be in multiple environments, how is that even possible if you think about it? You just do not have enough "machines".

You should be using Virtual Machines or Docker containers, I recommend Docker containers. Or just use more machines.

Just because you have the luxury of using different environments in IIS isolated web applications does not mean that a machine has the luxury of being in more than one environment. That is why Virtual machines and Docker containers exist, to break apart a machine into different environments and applications.

Upvotes: 3

Related Questions