简体   繁体   English

相当于App.config转换.NET Core?

[英]Equivalent to App.config transforms for .NET Core?

I'm writing a .NET Core console application ( NOT an ASP.NET Core web application). 我正在编写.NET Core控制台应用程序( 不是 ASP.NET Core Web应用程序)。 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. 在.NET Framework中,我将有一个App.configApp.Debug.config ,以及一个App.Release.config文件,后者用于转换前者。 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. 现在使用.NET Core,您的意思是使用appsettings.json 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? 那么如何以类似于.NET Framework中的方式转换配置文件呢?

The short answer that I found to this is: use SlowCheetah . 我发现的简短答案是:使用SlowCheetah It implements XDT transformations for .NET Core and in addition allows JSON transformations too with JDT. 它实现了.NET Core的XDT转换,此外还允许使用JDT进行JSON转换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM