I have a .net project that has a web reference to a service. I would like to update that web reference as part of every build. Is that possible?
-
2The web service and clients are written and used in house. I don't want to have to remember to manually update the web reference on every client project anytime time wsdl changes. – HBFan Oct 01 '08 at 21:00
4 Answers
You can use MSBuild script with a task that calls wsdl.exe
<Target Name="UpdateWebReference">
<Message Text="Updating Web Reference..."/>
<Exec Command="wsdl.exe /o "$(OutDir)" /n "$(WebServiceNamespace)" "$(PathToWebServiceURL)""/>
</Target>

- 757
- 1
- 9
- 17

- 16,360
- 5
- 30
- 37
-
2WSDL is for ASMX services only. The command-line tool for WCF doesn't perform the same job as Visual Studio's "Update Service Reference" – Panagiotis Kanavos Jul 24 '13 at 13:26
Also, when you are deploying your webservices on production make sure that they are set as Dynamic and not static.

- 19,710
- 36
- 144
- 222
You can do it using the methods provided by the other answerers, but you have to know that doing this could cause your build to fail. If the WSDL was changed, the generated code is also going to change and your code may no longer compile.

- 23,436
- 10
- 47
- 51
You can use svcutil (http://msdn.microsoft.com/en-us/library/aa347733.aspx) tool to generate the web reference for you. The tool will generate the proper client proxy classes and the proper config (and it can even merge it in your application config). Keep in mind that the tool requires .Net 3.0 and will generate WCF-style client proxies and configuration.

- 74,861
- 18
- 132
- 169