Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent to App.config transforms for .NET Core?

I'm writing a .NET Core console application (NOT an ASP.NET Core web application). In .NET Framework I would have an App.config, and App.Debug.config, and an App.Release.config file, the latter 2 for transforming the former. This allowed me to change various settings based on whether I was creating a debug or a release build.

Now with .NET Core, you're meant to use appsettings.json instead. Fine, but how do I do my debug and release transforms with this? I've read something about using an environment variable to determine whether you're in a release or debug environment but I really don't want to do this and it's not really appropriate for console applications anyway. So how can I transform config files in a similar way to how it was done in .NET Framework?

like image 385
Jez Avatar asked Nov 08 '18 13:11

Jez


People also ask

Is app config used in .NET core?

Application configuration in ASP.NET Core is performed using one or more configuration providers. Configuration providers read configuration data from key-value pairs using a variety of configuration sources: Settings files, such as appsettings. json.

Does .NET core still use web config?

ASP.NET Core no longer uses the Global. asax and web. config files that previous versions of ASP.NET utilized.

Does .NET core need web config?

In order to set up the ASP.NET Core Module correctly, the web. config file must be present at the content root path (typically the app base path) of the deployed app.

Is app config and web config are same?

When using Windows Forms or WPF etc, then you have the app. config which also stores ConnectionStrings. So yes they are similar but have different purposes.


1 Answers

The short answer that I found to this is: use SlowCheetah. It implements XDT transformations for .NET Core and in addition allows JSON transformations too with JDT.

like image 139
Jez Avatar answered Oct 15 '22 08:10

Jez