你如何设置解决方案配置特定的配置文件? [英] How do you set up solution configuration specific config files?

查看:129
本文介绍了你如何设置解决方案配置特定的配置文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有不同的环境(调试,测试,正式版)需要不同的设置Web服务。什么是这些不同环境设置不同的配置文件最简单的方法?一切,我在网上找到告诉我如何使用配置管理器来检索设置,而不是基于当前构建配置如何找到特定的设置。

I have a web service that needs different settings for different environments (debug, test, prod). What's the easiest way to setup separate config files for these different environments? Everything I find on the web tells me how to use configuration manager to retrieve settings, but not how to find particular settings based on the current build configuration.

推荐答案

我觉得有几个配置文件为每个环境效果很好。即:

I find having several config files for each environment works well. ie:


  • config\local.endpoints.xml

  • config\ dev.endpoints。 XML

  • config\ test.endpoints.xml

  • config\ staging.endpoints.xml

  • config\ prod.endpoints.xml

  • config\local.endpoints.xml
  • config\ dev.endpoints.xml
  • config\ test.endpoints.xml
  • config\ staging.endpoints.xml
  • config\ prod.endpoints.xml

然后我链接到这个使用内置的configSource属性中的主版本的web.config或app.config中,如

I then link to a "master" version of this using the built in configSource attribute within the web.config or app.config such as

<appSettings configSource="config\endpoints.xml"/>



我会再使用生成过程或部署过程中复制了正确的配置环境下至该名称在web.config期待。

I would then use the build process or deploy process to copy the the correct configuration for the environment down to the name that the web.config is expecting.

每个环境都是清楚的标记,控制,无需凌乱的占位符。

Each environment is clearly labelled and controlled, without the need of messy placeholders.

这篇关于你如何设置解决方案配置特定的配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆