简体   繁体   中英

vs.net xsd

In the past, I have used XSD.exe to create c# classes from an xsd. Today, I added an XSD to VS.NET 2008 SP1 and it automatically generated a dataset from my xsd, slick but I don't want a dataset. Is there a way to have vs.net automatically execute xsd.exe each time I modify my xsd.

Select the *.xsd file, open Properties Window (F4 key) and delete "Custom Tool" and "Custom Tool Namespace". This will remove the "DataSet" issue.

The "c# class from an xsd" issue can be solved by another custom tool. Look at XsdCondeGenTool - there is sample, how to do it.

我相信你最好的选择是将xsd.exe作为预构建事件运行,并将XSD的构建操作设置为“None”。

Whether xsd.exe generates datasets or classes depends on the command line arguments. Extract from xsd /?:

/classes Generate classes for this schema. Short form is '/c'.

/dataset Generate sub-classed DataSet for this schema. Short form is '/d'.

A pre-build event could help with updating your auto generated classes when the schema changes. You might want to consider Nant instead. Nant is a port for .Net of the Java build script Ant. With Nant you can create reasonably complex build scripts that will be able to invoke xsd.exe. I also imagine they could help call out to some scripts that could update your project file to reference the xsd generated classes (not something I've done but very doable I would think).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM