We tried using a wal approach that almost solved the problem, but we ran into problems with a one-click deployment, see my comment on wal's answer.
We are currently using the conditional compilation proposed in this publication:
http://www.codeproject.com/Articles/451734/Visual-Studio-Use-Conditional-Compilation-to-Contr
The advantage is that in addition to working flawlessly with a click once, you do not need to configure the VS project file or use third-party components. The downside is that you need to update the source code if you want to add / change the endpoint.
We did to add a new .setttings file to the project. This is not necessary, but we, although it was a good idea to save the endpoint configuration in a separate settings file, as this file should be slightly modified. It is configured to use conditional compilation to enable the correct endpoint based on the configuration included for compilation:
public ServiceSettings() { // // To add event handlers for saving and changing settings, uncomment the lines below: // // this.SettingChanging += this.SettingChangingEventHandler; // // this.SettingsSaving += this.SettingsSavingEventHandler; // // Each method corrsponds to a build version. We call all four methods, because // the conditional compilation will only compile the one indicated: this.SetLocalApplicationSettings(); this.SetAS12ApplicationSettings(); } [Conditional("LOCAL")] private void SetLocalApplicationSettings() { this["LoginAddress"] = "https://localhost/services/loginservice"; this["SettingsAddress"] = "https://localhost/services/settingsservice"; } [Conditional("EXAMPLE")] private void SetAS12ApplicationSettings() { this["LoginAddress"] = "https://example.com/services/loginservice"; this["SettingsAddress"] = "https://example.com/services/settingsservice"; }
In VS, we created one configuration per endpoint and determined the correct conditional compilation symbol in the Build tab, i.e. LOCAL or EXAMPLE.
We also updated the code using the WS client classes created by VS to use the endpoint defined in the settings file:
var client = new SettingsServiceClient("SettingsServiceImplPort", ServiceSettings.Default.SettingsAddress);
In app.config, we just saved the default configuration (localhost) and the binding configuration to keep VS happy:
<system.serviceModel> <bindings> <customBinding> <binding name="SettingsServiceImplServiceSoapBinding"> <textMessageEncoding messageVersion="Soap12" /> <httpsTransport /> </binding> <binding name="LoginServiceImplServiceSoapBinding"> <textMessageEncoding messageVersion="Soap12" /> <httpsTransport /> </binding> </customBinding> </bindings> <client> <endpoint address="https://localhost/services/settingsservice" binding="customBinding" bindingConfiguration="SettingsServiceImplServiceSoapBinding" contract="SettingsServiceReference.SettingsService" name="SettingsServiceImplPort" /> <endpoint address="https://localhost/services/loginservice" binding="customBinding" bindingConfiguration="LoginServiceImplServiceSoapBinding" contract="LoginServiceReference.LoginService" name="LoginServiceImplPort" /> </client> </system.serviceModel> <applicationSettings> <ConfigurationTest.ServiceSettings> <setting name="SettingsAddress" serializeAs="String"> <value>https://localhost/services/settingsservice</value> </setting> <setting name="LoginAddress" serializeAs="String"> <value>https://localhost/services/loginservice</value> </setting> </ConfigurationTest.ServiceSettings> </applicationSettings>