Gotcha with ASP.NET Core environments on Linux

Recently I was working on a interesting project within a company I work for.

One of the parts of the project is a web app that enables users to easily (through a wizard) add build pipeline to their repository.

We decided to build this application by using ASP.NET Core, run it on Linux and naturally deploy it in a Docker container. This all worked very nice!

Next step was to actually manage this properly and to split dev and production settings and environments. ASP.NET Core has a nice way to do this. You can read about it here.

But

There is one "tricky" section in the document. Where they talk about ASPNETCORE_ENVIRONMENT environment variable. Here is what it states:

The specified environment name is case insensitive. Whether you set the variable to Development or development or DEVELOPMENT the results will be the same.

Unfortunately, that is not the case for Linux.

Linux is case sensitive. That means, that if in your code you use env.EnvironmentName and use it to, for example, find a configuration file for production, it will not work correctly if you did not match the case in environment variable value with the case of your files name.

Keep that in mind. It's one of those super stupid bugs that take too much time to figure out.

I have reported this and it's already being fixed. Kudos to the docs team!