MSBuild配置文件 [英] MSBuild Configuration Files

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

问题描述

我是MSBuild的一名新手,我想在NANT上使用它.

I'm a complete newbie to MSBuild and I want to use it over NANT.

我想要在调试模式下运行构建并使用app.configA,然后在舞台中使用app.configB,在生产环境中使用app.configC.

What I'm wanting is to run a build in say debug mode and to use app.configA, then in Stage use app.configB and in Production use app.configC.

我认为这都是可行的,但是有人可以指出我的设置方向吗?

I presume this is all doable but can anyone point me in the direction on how to set this up?

推荐答案

如果您可以忍受MSBuild的copy语句带来的痛苦,那么您可以在构建后事件中执行以下操作:

If you can endure the excruciating pains of MSBuild's copy statement, then you can do something like this as a post-build event:

<Copy Condition="'$(Env)' != ''" SourceFiles="$(WhereverTheDeployedAppIs)\web.$(Env).config" DestinationFiles="$(WhereverTheDeployedAppIs)\web.config" />

现在让我们来看一下.

$(Env)是环境.您必须通过构建脚本来传递它.

$(Env) is the environment. You'll have to pass that in via your build script.

SourceFiles设置为配置文件的原始名称(例如,Web.MyFavoriteEnvironment.config).

SourceFiles is set to the config file's original name (Web.MyFavoriteEnvironment.config, for example).

DestinationFiles设置为相同的东西,仅缩短为Web.config,覆盖以前的任何Web.config.这就是您的应用程序将要使用的.

DestinationFiles is set to the same thing, only shortened to Web.config, overwriting whatever Web.config was there before. This is what your app will use.

将其按摩到您的应用配置文件命名约定.

Massage this to your app config file naming convention.

现在...

尽管这对我的团队有效,但我真的希望,为了您的缘故,有人能发布更好的东西.

Although (something like) this works for my team, I really hope, for your sake, that someone posts something better.

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

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