I have a C# solution in Visual Studio 2005. There is a web reference in one project that I have to change when I have to build the project for a determined environment, manually deleting the reference from Visual Studio, and adding a new one with the same name, but changing the url.
I would like to make this manual process of adding the web reference not so tedious.
I would like to have in the configuration manager, besides debug and release configurations, development, pre-production and production configurations, each of them determining the correct web-reference associated to the specific environment.
I was thinking of creating a preBuild event (a .bat file maybe), where depending on the Build Configuration, the web reference would be created correctly.
I am not sure about how to do this. I have some questions about it:
1) I could create different "app.config" files, where the properties
<setting name="MyService_serviceagent" serializeAs="String">
<value>developmentEnvironmentURL</value>
</setting>
would be different depending on the environment, and I could copy the right app.config file depending on the selected configuration.
Would this re-generate the Reference.cs file from the web reference? (I guess not). Would this be a problem even if the interface has not changed, or it would be enough if I regenerate the webreference manually only when I want to re-generate the class?
2) Is a bad idea to do this ? Do you think of any alternatives, or is it easier to just accept that I should delete and add the corresponding web reference when I want to build my solution pointing to a determined environment?
Thank you for reading : )
Regards.