开发者

Correct way to Switch between Dev, Test and Prodcution Services in Builds

I have a client side app (WPF) that hits my web services.

When I am running in dev I want to开发者_高级运维 hit the Dev version of these web services. When I am running in the Test environment I want to hit the test version of the services. Like wise for production.

Since these values are in my app.config file what is the best way to switch between them?


Another single config file way would be to do something along the lines of:

<add key="Service-DEV" value="serviceUrl"/>
<add key="Service-UAT" value="serviceUrl"/>
<add key="Service-PROD" value="serviceUrl"/>

If your app knows which environment it's running in you could then just pull which one you need.

Up to you though. I've also used the multiple config approach with deployment scripts that deploy the correct file to the requested deployable environment.


Are you wanting to switch when you build the app? NAnt may be a way to handle this, or using options within Visual Studio possibly as there is a debug and release build modes.

For the few times I've had to do something similar, I prefer tweaking the hosts file on the client machine so that I can use the same DNS for dev,test and production. I'm not sure if that is practical or not in your case.


I typically maintain 3 separate config files and manually switch them when I install. Scott Hanselman has an article on how to use the build modes along with pre-build events to automatically switch between various configurations. Investigating this as an alternative is on my list of things to do so I can't tell you how well it works in practice.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜