Create WCF proxies as part of the build process

I am writing a WCF service that will be widely used inside our company, and I would like to generate WCF proxies as part of the assembly process and pack them into an assembly so that the service clients do not "Repeat this process at their end many times. Is there a way, Does anyone know about this? Are there any predefined build tasks for MSBuild?

+5
source share
6 answers

Here is what I did:

1) Create a project that has a service for which I want to generate client code

2) Create an MSBuild task that does the following:

a) Takes the compiled WCF Service assembly, runs svcutil.exe on it to extract XSD and WSDL metadata for all the services in the Service assembly.

b) Runs svcutil.exe again, this time on the extracted XSD and WSDL files to generate a .cs file containing the client

c) Run csc.exe to compile the generated client code into a separate assembly.

3) Insert the MSBuild task into the "AfterBuild" target of the project containing this service.

, , , , , - . , , , -. - , MSBuild XML .

+3

. . .csproj, AfterBuild, SDK Exec svcutil.exe. " .

<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>
+3

- , :

, - svcutil . MSBuild script, (1) svcutil (2) .

, ?

0

MSBuild - , ( ). / MSBuild XML!

0

T4 , T4Toolbox

-1

Why not just create a separate class library project. In this project, use the "Add Service Link" for each of the services you need.

Other code might just use classes in the class library.

-1
source

All Articles