[英]Multiple Appsettings.json for Command Line Applications?
I have a console app in.Net 6 and wondering how can I have multiple appSettings files?我在 .Net 6 中有一个控制台应用程序,想知道如何拥有多个 appSettings 文件?
I want to have one for我想要一个
appsettings.development.json appsettings.test.json appsettings.production.json appsettings.development.json appsettings.test.json appsettings.production.json
I will be deploying the console application onto windows servers and hooking it up to a scheduled task.我将把控制台应用程序部署到 windows 台服务器上并将其连接到计划任务。 Depending on which environment I want a different appsettings to be used.
根据我想要使用不同的应用程序设置的环境。 I am not sure how to do this.
我不知道该怎么做。
I think I would have to create an environment variable on each server to make it use the right file but hoping there is more a coding way automatically use the right appsettings file.我想我必须在每台服务器上创建一个环境变量以使其使用正确的文件,但希望有更多的编码方式自动使用正确的 appsettings 文件。
I found this posting that seems to be almost what I need but it is for web apps and not console apps我发现这篇文章似乎几乎是我所需要的,但它适用于 web 应用程序而不是控制台应用程序
Automatically set appsettings.json for dev and release environments in asp.net core? 自动为 asp.net 核心中的开发和发布环境设置 appsettings.json?
You can pass environment variable via line argument, like this您可以通过行参数传递环境变量,就像这样
C:\Myapp.exe --environment Development
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.