'Have vs.net automatically execute xsd.exe everytime time xsd is modified
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.
Solution 1:[1]
I believe your best bet would be to run xsd.exe as a pre-build event, and setting the build action for your XSD to "None".
Solution 2:[2]
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.
Solution 3:[3]
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).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | user19371 |
| Solution 2 | TcKs |
| Solution 3 |
