简体   繁体   English

多个 Appsettings.json 用于命令行应用程序?

[英]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.

相关问题 Serilog 多个文件 appsettings.json - Serilog multiple files appsettings.json 如何在命令行安装过程中使用作为参数传递的值从wix自定义操作更新appsettings.json? - How to update appsettings.json from wix custom actions with the values passed as parameter during command line installation? 在 C# 10 Z303CB0EF9EDB9082D61BBBE572AZ 中使用命令行 Arguments 重写 IConfiguration appsettings.json - Rewriting IConfiguration appsettings.json with Command Line Arguments in C# 10 .NET 6 如何在项目appsettings.json中配置多个QnA模型? - How to configure multiple QnA models inside projects appsettings.json? 将连接字符串移动到appsettings.json - Move connectionstring to appsettings.json Map appsettings.json 到 class - Map appsettings.json to class 在运行时检索 appSettings.json - Retrieve appSettings.json at runtime 添加链接的 appsettings.json - Add a linked appsettings.json 我们可以使用单个 appsettings.json 文件,而不是为不同的环境维护多个版本的 appsettings.{environmentname}.json 吗? - Can we use a single appsettings.json file instead of maintaining multiple versions of appsettings.{environmentname}.json for different environments? Serilog 使用 appsettings.json 而不是 appsettings.Development.json - Serilog using appsettings.json instead of appsettings.Development.json
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM