none
How to automatically update the .svc service reference

    Question

  • While automating the build using MSBuild, i'm stuck as how to update the service reference before compiling the website. Is there a way to update it dynamically as a prebuild event in the msbuild project file itself. Also i have multiple service references. So I will have to update those which have changes. This is how i do it manually as of now - Update the reference whenever error is thrown to update a particular reference at the time of building the website. 

    Does anyone knows how to do it? Or is there a better approach to it. 

    Thursday, December 07, 2017 6:55 PM

All replies

  • You can use the SVCUTIL utility to regenerate the proxy class from the service WSDL. A call to svcutil with appropriate parameters can be done from msbuild.

    https://docs.microsoft.com/en-us/dotnet/framework/wcf/servicemodel-metadata-utility-tool-svcutil-exe

    Thursday, December 07, 2017 10:02 PM
  • Hello Aravinth0510,

    According to your question is more related to MSBuild, I will move the thread to MSBuild forum for suitable support.

    If you have some grammar or code errors in using C#, please feel free to contact us. We will try our best to give you a solution.

    Sincerely,

    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, December 08, 2017 1:43 AM
  • Hi Alberto Poblacion,

    As Alberto said, we could use SvcUtil to upgrade the WCF reference. Please add the following code to your prebuildevent.

    Note: please modify related folder path, service path as your

    "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\svcutil.exe" /directory:"Connected Services\ServiceReference1" /noConfig /out:"Reference.cs"  http://localhost:65457/Service1.svc

    Best regards,

    Zhanglong Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, December 08, 2017 4:39 AM
    Moderator