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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With