Been using XSD.exe for years from the command line to generate XSD. Recently I decided to add it to the Visual Studio IDE so I can simply click the class file in solution explorer and generate an XSD.
- Open Visual Studio and go to Tools->External Tools
- Click Add and name the menu item “Class to XSD”
- Add the command, browse for XSD.exe
- Add arguments, $(BinDir)$(TargetName).dll /outputdir:$(ItemDir) /type:$(ItemFileName)
That’s it! You should have something looking like the below. To use it go to your .cs file in solution explorer and click it. Then go to Tool->Class to XSD. The .xsd files will be created in the same folder as your classes.