1.

Solve : running Visual studio Command prompt or XSD.exe from a batch file.?

Answer»

Can someone help me with a way (or script) to run a visual studio command PROMPT or XSD.exe tool to convert an XML file to XSD and later to a .Net class (using C# lang). I want to write a .bat file that runs this tool (VS command prompt or XSD.exe) with suitable parameters and convert an xml (from a location of a file) into a xsd and then into a class. Any help would be APPRECIATED

Thanks a lot in advance.A visual studio command prompt is result of a standard command window after vcvarsall.bat has been run. Basically a mess of Visual Studio directories are added to the beginning of your standard path.

The XSD utility will generate class files from a source.

Based on your post, I think you would need this format:

Code: [Select]xsd <instance>.xml [/outputdir:]

Hope this gets you started. Thanks SideWinder for your quick response.
I basically wanted to create a tool (using winform) that will take the xml string or a location where this xml string is located and generate a class and place it in some directory. But to generate a .Net class we need an xsd. I know that using VS command prompt or XSD.exe we can generate an xsd from xml and later using the same command promt, to genererate a class from the xsd. But I dont want the user to do all this manually. I am thinking of AUTOMATING this, so that just by entering the xml the user should get a class.

I am thinking of using the xsd.exe or VS cmd prompt in another batch file which will do everything step by step by giving suitable PARAMS. Do you think it will be possible?

Thanks a lot once again :-)This should help you out. The script works on-demand. If you want to automate an entire directory of XML files, this script can be reworked.

Code: [Select]@echo off
set arg=%*

:loop
if "%arg%"=="" (
set /p arg=Enter XML Name:
GOTO loop
)
drive:\path\xsd drive:\path\%arg%.xml /outputdir:%temp%
if not errorlevel 1 drive:\path\xsd %temp%\%arg%.xsd /classes /language=CS /out:%temp%

You'll need to fix up the drives and paths. Also you might want to change the %temp% variable. I only used it because all Vista machines have it defined.

Good luck. thanks again sidewinder.
That's very helpful. I'll look into this.
Bye.
jet.



Discussion

No Comment Found