In this short How-to guide we will show you with an example how to generate multiple schemas by script.
It is useful to be able to generate several schema at once. For example, if you have a large number of schema and they are updated to a new version. It can take a long time to go through the schema generation one schema at a time, building a script can be a considerable time saver.
In another context, it can also be useful to generate the code from a build server. For example when a check-in is performed on one or more schemas. Or simply when a compilation is triggered on the build server. As you can see, there are many reasons to automate these processes.
The example script below allows to select all the schemas of a directory and to generate one by one the corresponding classes. The Parameters variable contains code generation options that you can customize to suit your needs.
The documentation that details all the command line options can be found here : How to run from command-line tool
@echo off set WorkingFolder=c:\temp set Parameters=/p NetCore /classinfiles set Extension=.xsd set X2C=C:\Program Files(x86)\Xsd2Code\xsd2code.exe for %% f in (% WorkingFolder %\*% Extension %) do ( echo "fullname: %%f" echo "%X2C%" %% f % Parameters % "%X2C%" %% f % Parameters % ) pause