Dot Net Development – How to Develop Multiple Environments In .NET Core

Dot Net Development - How to Develop Multiple Environments In .NET Core

The advent of .Net Core has resulted in a wide number of enhancements for both personal and business solutions. You don’t need to learn multiple deployment pipelines and development environments if you know .Net Core. Therefore, tutorials and online courses don’t cover this essential knowledge when advancing to a production-ready program. This article will demonstrate how to develop several .Net Core application environments correctly. 

The grouping of the software, hardware, and tools required for creating and using the program is referred to as an environment in the context of software development. By using several environments, one can be sure that the program is fully tested before being released to users. 

Various Hosting Environments That Companies Should Leverage

In any enterprise software, different hosting environments are set up for different purposes. The dot net development company works in one, testers test in another, and eventually, the end users access the finished product in another environment.

Every organization typically uses three environments: 

  • Development: A tool used by developers to create applications. 
  • Testing: Testing teams should use staging to find as many bugs as they can.
  • Production: The application’s ultimate iteration, ready for the use of the end-user.

For every environment, development teams must configure settings. For instance, in a production environment, an application error should only display a user-friendly message to the user. However, developers don’t require it at all in a development environment. For them to be able to correct the issue, they require comprehensive information about it. Therefore, separate settings should be used in each environment, which can be specified in the application code’s configuration files.

The Impact of Environments on the Coding Process

The Environments control the settings including app configurations, third-party package configurations, service configurations, features that must be enabled or deactivated on a per-environment basis, and more. The application might not work successfully in every setting if it isn’t properly configured, forcing developers to redo their code. 

Therefore, before delivering it to the environment, it is essential to examine and change the environment settings appropriately. Thankfully, software development services company support environment detection and loading the appropriate configuration via codes.

Dot Net Core: Multiple Environments

Consider having three environments, which are Development, Staging, and Production. Users must execute or load various configurations in these environments. Using variables referred to as “Environment Variable,” Asp.Net Core enables users to distinguish between various settings. The variable to which users are alluding is ASPNETCORE_ENVIROMENT. This will enable them to customize their environment. Development, staging, and production are the prevalent values. 

After this variable is set up, one may determine at runtime its value as well as the environment in which the application is being used. Users must keep in mind that in Linux, names are case-sensitive. Thus, it is a good practice to save files and configurations accordingly.


Users will work in this environment while they create their application. How will it be set up? Right-clicking on the project and choosing configuration will open a window where “Debug” must be chosen from the left-hand tab.

Keep in mind that anytime this screen is altered, the launch file within the settings folder receives the modified configuration. Users can add whatever environment they want to this file. Any changes they make to these parameters in the file won’t be reflected right away. Once updated, the servers must be restarted for Kestrel to be able to properly detect the change.


This is the setting employed as a test or development environment, usually, as a last check before moving on to production. To minimize the impact of deployment, this environment should always be a production mirror. 


This is the setting that is frequently referred to as “Alive.” It is a setting where the application’s security, speed, and dependability parameters are set. The following traits of the manufacturing environment include: 

  • Enable cache-related features 
  • Packages, compressing JS and CSS files, or CDN (Content Delivery Network) settings are examples of client-side file settings. 
  • Turn off the diagnostic features. 
  • Enable the options for logging and monitoring.
  • Depending on the demands of each application, the list may be longer.

Setting Up Environments

When the application is operating on Windows, use the settings by means of: 

  • The command lines 


  • PowerShell 

$ Env: ASPNETCORE ENVIRONMENT = “Development” 

The window in which these commands are being executed is the only window in which they will be validated. If it is shut down, this configuration will be lost. To set the value to be global, go to Control Panel > System > Advanced System Configuration and add the ASPNETCORE ENVIRONMENT variable. 

The following bash command must be used on macOS: 

ASPNETCORE_ ENVIRONMENT = Run dotnet development 

The variables must be set up at the operating system or machine level in the.bashrc or.bash.profile files. Editing the file requires adding the following: 

export ASPNETCORE_ ENVIRONMENT = Development 

In Linux, one must either alter the bash_profile file for the entire operating system or computer or use the export command for the open session.

The Conclusion

In conclusion, Asp.Net Core has a variety of features that developers can benefit from. It also gives a lot of command over the environments wherein developers typically work. With this configuration, users can easily alter the value of the environment variable to alter the behavior of their program.

Published by: Martin De Juan

Share this article

This article features branded content from a third party. Opinions in this article do not reflect the opinions and beliefs of Kivo Daily.