tags:

views:

27

answers:

1

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

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?

+2  A: 

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" />

Now let's go through that.

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

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

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.

Now...

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

apollodude217
+1 Wow, a little cpryptic and painful. i was looking for some simple reference sites if you have any.
griegs