Is it possible to use svcutil to reuse/exclude referenced types, as with visual studio.
I have multiple projects, my types/datamodels are stored in separate assembli
If you run svcutil
without arguments, you'll see it has several functions. I think you could do what you want with two invocations:
svcutil /serviceName:<myServiceName> <pathToAssemblyWithConfigFile>
. This outputs .wsdl and .xsd files.svcutil /reference:<assemblyPath> *.wsdl *.xsd
.I've tried doing this in one step before, but when svcutil is in "code generation" mode, it expects metadata as input, not assemblies. So generate metadata first!
svcutil /?
gives
/reference:<file path> - Add the specified assembly to the set of assemblies used for resolving type references. If you are exporting or validating a service that uses 3rd-party extensions (Behaviors, Bindings and BindingElements) registered in config use this option to locate extension assemblies that are not in the GAC. (Short Form: /r)
So running svcutil
with /r:myassembly.dll
should make it.
Thanks for your help. Got this working eventually with the following commands:
SET BACKENDROOT=C:\SomePath\Development\Backend\bin
SET DATAMODELSBASE=C:\SomePath\Development\DataModels\bin
SET OUTFOLDER=C:\SomeOutputFolder
SET REFRENCED_ASSEMBLIES=/r:%DATAMODELSBASE%\Jall.DataModels.Consignment.dll
SET REFRENCED_ASSEMBLIES=%REFRENCED_ASSEMBLIES% /r:%DATAMODELSBASE%\Jall.DataModels.SomethingElse.dll
SET SVCFLAGS=/enableDataBinding /s /a /tcv:Version35
::Generate metadata
svcutil %BACKENDROOT%\Jall.Backend.Consignment.DLL /t:metadata -d:%OUTPUTFOLDER%
::Generate proxy with shared types
svcutil %OUTPUTFOLDER%\*.wsdl %OUTPUTFOLDER%\*.xsd %SVCFLAGS% /ser:DataContractSerializer %REFERENCED_ASSEMBLIES /o:test.cs
Note that the /ser:DataContractSerializer had to be used for this to work. And another annoyance is that if types such as datatables/datasets etc is used (not that they really should though) their assemblies have to be included or svcutil will mess up generating the metadata.
IE:
SET SHAREDASSEMBLIES=%SHAREDASSEMBLIES% /r:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll