Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
635 views
in Technique[技术] by (71.8m points)

.net - svcutil exlude/reuse refrenced assemblies

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 assemblies, so they can be used by other non wcf projects etc. When updating refrences in the visual studio gui, this all works out just fine. As long as a type is found on both sides of the border, it's excluded from beeing defined in the proxy.

How can I achieve the same thing using svcutil?

More clearly I want to generate the proxy from a dll, not a running service which contains the servicecontract. At the same time I want to feed the dll files containing the shared types, which should be excluded from beeing defined in the proxy.

The reason for all this is for allowing my projects to be updated and built on a buildserver.

Edit: First of thank you for your reply and suggestion of parameters. However I'm not getting svcutil reusing the assemblies following your instructions.

Here is parts of the .bat file I made I've excluded all the flags for generating INotifyPropertyChanged etc.

SET BACKENDROOT=C:SomePathDevelopmentBackendin
SET DATAMODELSBASE=C:SomePathDevelopmentDataModelsin
SET COMMONBASE=C:SomePathDevelopmentCommonin

SET REFRENCED_ASSEMBLIES=/r:%DATAMODELSBASE%Jall.DataModels.Consignment.dll

svcutil %BACKENDROOT%Jall.Backend.Consignment.DLL /t:metadata
svcutil /o:test.cs %REFRENCED_ASSEMBLIES% *.wsdl *.xsd

The result is as follows:

[System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
   [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://schemas.datacontract.org/2004/07/KSD.DataModels.Consignment")]
public partial class ExtInvoice : OrmBase
{

private System.DateTime buyersOrderDateField;

private bool buyersOrderDateFieldSpecified;

private string buyersOrderNumberField;

private string compCodeField;
.....

And in the client it self:

public Address CreateNewAddress(int TK, string AddressType)

This is incorrect the datamodels are generated directly in the proxy. The client doesn't just skip them and use the proper namespace for the types. The correct result should be:

public Jall.DataModels.Consignment.Address CreateNewAddress(int TK, string AddressType)

(Names are scrambeled :) )

Brgds, Stian

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...