How to? Excluding referenced types while generating DTOs [modified]
-
I've googled this to the point of absolute frustration without success, but it's what I would consider a noob question I'm hoping someone can help me with. There has been a lot of close-but-not-quite conversation on the interwebs about my issue so I'm going to be as explicit as I can (aka verbose ... sorry). My goal is to use svcutil to generate my datacontracts which are also my DTO's for my WCF service. Everything works great until i have a datacontract that contains another datacontract ... and it does work ... except I have to manually go into the referencing generated class and remove the duplicated definition ... EVERYTIME I regenerate. I thought the svcutil /excludetype (/et) option would do this but I can't get it to work. Here is an illustration: I have an .xsd file that looks like this: (I'm leaving out the headers removing all but a single property to keep it simple. In reality there is obviously a lot more to this than a phone number.)
<xs:complexType name="ContactDTO">
xs:sequence
<xs:element minOccurs="0" maxOccurs="1" name="PhoneNumber" type="xs:string" />
xs:sequence
xs:complexTypeI run it through svcutil and it generates my datacontract perfectly and I get a ContactDTO.vb class. But then I have another xsd that references the first like so: (again.. greatly simplified to not waste your time)
<xs:include schemaLocation="ContactDTO.xsd"/>
<xs:complexType name="CustomerDTO">
xs:sequence
<xs:element minOccurs="0" maxOccurs="1" name="CustomerName" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="1" name="Contact" type="ContactDTO" />
xs:sequence
xs:complexTypeAfter a bunch of trail and variation I've landed on using the following command line to generate the classes:
svcutil /dconly ./CustomerDTO.xsd /n:http://mynamespacegoeshere.ccc/Schemas, /out:./Classes/CustomerDTO.vb /language:VB ./ContactDTO.xsd /et:ContactDTO.xsd
And like i said, it does work ... but I get two classes, the CustomerDTO.vb class which I want and ANOTHER copy of the ContactDTO.vb class that has already been generated previously and i have to go into my generated classes and hand edit the duplicates out. Now I could just not generate the first class however the point is resuse ... so I have several OTHER classes that reference ContactDTO and I have to edit out every instance of the duplicate generated cod