C#我们可以有一个项目的多个.config文件? [英] C# can we have multiple .config file for a project?

查看:454
本文介绍了C#我们可以有一个项目的多个.config文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我们可以有多个.config文件,我们可以与其他项目共享一个配置文件,并将私有配置放入另一个。 Visual Studio 2008将被混淆?

If we can have more than one .config files, we can share one config file with other projects and put private configuration into another. Visual Studio 2008 will be confused?

推荐答案

Visual Studio 2010支持多个.config文件。它是新的Web应用程序打包和部署系统的一个特性。我们可以为我们为应用程序的每个配置创建现在单独的web.config文件。但是对于2008年,不支持多配置文件,你可以通过添加两个配置文件并在构建时重命名它们。

Visual Studio 2010 has support for multiple .config files. It is one feature of new web application packaging and deployment system. We can create now separate web.config files for each configuration we have for application. But for 2008 there are no support for multi config files, you can workaround this by adding two config files and rename them in build time

示例:

private.config
public.config

private.config public.config

在pre-msbuild事件上合并这两个文件

on pre-msbuild event merge these two files

重命名合并文件,应该是web.config或app.config

rename merged file, it should be web.config or app.config

希望这有助于...

s

这篇关于C#我们可以有一个项目的多个.config文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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