Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate WCF proxies as part of the build process

Tags:

proxy

wcf

msbuild

I'm writing a WCF service which is going to be used extensively within our company, and I'd like to generate WCF client proxies as part of the build process and package them within an assembly so that clients of the service don't have to repeat this process on their end numerous times. Is there any way that anybody knows of to accomplish this ? Are there any pre-existing build tasks for MSBuild ?

like image 847
Alex Marshall Avatar asked Jul 17 '12 20:07

Alex Marshall


1 Answers

I was trying to solve the same problem. Here's what ended up doing. In the .csproj, under AfterBuild target, add a task to fetch the SDK path, and use the Exec command to run the svcutil.exe. I had to use " because the path contains spaces.

<Target Name="AfterBuild">
   <GetFrameworkSdkPath>
       <Output TaskParameter="Path" PropertyName="SdkPath"/>
   </GetFrameworkSdkPath>
   <Exec Command="&quot;$(SdkPath)bin\NETFX 4.5.1 Tools\svcutil.exe&quot; $(TargetPath)"/>
</Target>
like image 167
Alon Catz Avatar answered Nov 15 '22 11:11

Alon Catz