Working with multiple environments and vNext best practice

The new ASP.NET documentation under Fundamentals/Working with Multiple Environments it has a detailed description of how to handle multiple environments (surprise surprise) in code.

I was wondering if this is the “best practice” when dealing with multiple environments or should it be handled by something other than code like the tool that is doing the deployment for example?

At my workplace we have many test environments to manage, and we generally run a .NET stack for websites. We currently use Octopus Deploy which, for each environment, will configure applications at deploy time. Our apps are built and packaged up with replaceable variables which Octopus fills in on deployment.

Even if you don’t use such a tool I would recommend configuration at deployment time. Your application that you package up (in your CI tool of choice) for deployment should be the same repeatable package that goes into dev, test and prod. We use Team City which builds our deployment packages, and another tool which is a package repository to store all the build artefacts.

Having code paths that are special for an environment potentially makes testing harder since your application is behaving differently.


  1. Continuous integration which compiles all code as it checks in and runs unit tests.

  2. As in point 1 plus variant or parameterized builds. Build for windows server. Build for linux server. Etc.

  3. For internal components or shared assemblies one or multiple private nuget feeds may be desirable.

  4. A devops culture may be useful.

  5. A strategy for continuous deployment of systems composed of subcomponents often tagged as microservices may be useful for webapi services.

  6. Blue/green deployment may be useful. See

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *