简体   繁体   English

来自项目配置的参考解决方案配置

[英]Reference solution config from project config

I am new to .NET but taking over a solution from another developer. 我是.NET的新手,但从另一个开发人员那里接过一个解决方案。 The solution has 12 separate projects and each project has 9 AppSettings.config files based on different test and production environments. 该解决方案有12个独立的项目,并且每个项目都有9个基于不同测试和生产环境的AppSettings.config文件。 Each of these enviornment config files have some appsettings that are always the same across all config files. 这些环境配置文件中的每一个都具有一些在所有配置文件中始终相同的应用程序设置。 I would like to have 1 solution/global config file that can be referenced within each of the 9 project config files. 我希望有1个解决方案/全局配置文件,可在9个项目配置文件中的每个文件中引用。

If you want to have global and local settings at the same, that is very difficult to achieve. 如果要同时具有全局和本地设置,则很难实现。

If all config files are the same, you could link the files from one source. 如果所有配置文件都相同,则可以从一个源链接这些文件。

https://andrewlock.net/including-linked-files-from-outside-the-project-directory-in-asp-net-core/ https://andrewlock.net/including-linked-files-from-outside-the-project-directory-in-asp-net-core/

Can you reference an other config file for a specific section: https://docs.microsoft.com/en-us/dotnet/api/system.configuration.sectioninformation.configsource?view=netframework-4.7.2 您能否参考特定部分的其他配置文件: https : //docs.microsoft.com/zh-cn/dotnet/api/system.configuration.sectioninformation.configsource?view=netframework-4.7.2

This way you could share the same connectionstrings across all projects. 这样,您可以在所有项目中共享相同的连接字符串。

For more difficult things you will have to setup something yourself. 对于更困难的事情,您将必须自己进行设置。

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

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