管理web.config文件中 [英] Managing web.config files

查看:225
本文介绍了管理web.config文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个环境:开发,QA​​,在.NET 4每个都​​有一个唯一的web.config文件正式版。我们一直有管理所有三个版本的问题。它很容易忽视一些关键手动合并TFS中的web.config文件时。不止一次,我们已经结束了一个连接字符串指向QA的正式版。

因此​​,<一个href=\"http://blogs.msdn.com/b/webdevtools/archive/2009/05/04/web-deployment-web-config-transformation.aspx\"相对=nofollow>我的web.config文件的转换阅读起来。的这些似乎需要MSBUILD。我们没有构建服务器,所以我不知道我怎么可以尝试使用这一解决方案。有没有一种方法,使变革与正常的网络工作发布?

你有管理3 web.config文件中任何其他建议?


解决方案

  

有没有一种方法,使转变
  与正常的网络工作发布?


当然,看看这个MSDN链接。你不需要MSBUILD。您可以在不同的配置文件的各种环境设置连接字符串。例如,你可以有Web.config中,Web.QA.config和Web.Prod.config,其中QA和正式版是分开的 Visual Studio中构建配置的。

另外,你可以只使用默认被添加的构建配置:Web.config文件(本地开发),Web.Debug.config(用于QA)和Web.Release.config(用于生产)。

使用该设置作为一个例子,Web.config中将具有所有的配置,Web.Debug.config将只有对于该环境的变化(连接字符串,应用设置等)的配置,以及Web.Release.config具有只是对于环境改变配置。

一旦你的CONFIGS和转换都设置,你只需要改变你的构建配置,建立并从Visual Studio发布。

I have 3 environments: Dev, QA, Prod on .NET 4. Each has a unique web.config file. We have been having problems managing all three versions. Its easy to overlook something critical when manually merging web.config files in TFS. More than once we have ended up with a connection string pointing to QA on Prod.

So, I read up on web.config transformations. These appear to require MSBUILD. We have no build server so I'm not sure how I can attempt to use this solution. Is there a way to make transformations work with a normal web publish?

Do you have any alternative suggestions for managing 3 web.config files?

解决方案

Is there a way to make transformations work with a normal web publish?

Absolutely, take a look at this MSDN link. You do not need MSBUILD. You can set your connection strings for your various environments in separate config files. For example, you could have Web.config, Web.QA.config, and Web.Prod.config, where QA and Prod are separate Visual Studio Build configurations.

Alternatively, you could just use the build configurations that are added by default: Web.config (local development), Web.Debug.config (use for QA), and Web.Release.config (use for production).

Using this setup as an example, Web.config would have all configuration, Web.Debug.config would have only the config that changes for that environment (connection strings, app settings, etc), and Web.Release.config has only the config that changes for that environment.

Once your configs and transformations are setup, you just change your build configuration, build and publish from Visual Studio.

这篇关于管理web.config文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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