Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The best way to manage multiple client endpoint configurations (IP-address etc) in app.config

We developing a system where the client application is a .NET client communicating with a server using web services. We need to be able to deploy the client with different configuration options, e.g. IP address etc. So far we have managed this by basically commenting/un-commenting different configurations in app.config, like:

<!--<client>
    <endpoint address="https://localhost/services/service1"
        binding="customBinding" bindingConfiguration="ServiceSoapBinding"
        contract="ServiceReference.Service1" name="ServiceImplPort" />
    <endpoint address="https://localhost/services/service2"
        binding="customBinding" bindingConfiguration="ServiceSoapBinding"
        contract="ServiceReference.Service2" name="ServiceImplPort" />
    ...
    ..
</client>-->
<client>
    <endpoint address="https://prod.example.com/services/service1"
        binding="customBinding" bindingConfiguration="ServiceSoapBinding"
        contract="ServiceReference.Service1" name="ServiceImplPort" />
    <endpoint address="https://prod.example.com/services/service2"
        binding="customBinding" bindingConfiguration="ServiceSoapBinding"
        contract="ServiceReference.Service2" name="ServiceImplPort" />
    ...
    ..
</client>

But it seems obvious that this is not the best solution to the problem, it becomes a bit unmanageable as the number of configuration alternatives grow. Any suggestions how to improve this are most welcome.

Regards, Ola

like image 700
Ola Theander Avatar asked Oct 07 '22 15:10

Ola Theander


1 Answers

Fortunately there is a great solution to this problem. Download and install MSBuild.Community.Tasks

Then check out the following posts for example usage

http://chris.widdowson.id.au/?p=781

http://grahamrhay.wordpress.com/2012/03/16/multiple-config-transforms-at-build-time/

warning it takes longer than 5 minutes to set up and you will be editing your .csproj file by hand

This solution does work very well, come back with any issues

like image 142
wal Avatar answered Oct 12 '22 11:10

wal