Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate xsd from C# class file using visual studio command prompt?

I'm using the following command, but it's not working:

C:\Program Files (x86)\Microsoft Visual Studio 8\VC\bin>xsd /c /l:cs SubsystemReg.cs

Lets say this is my Class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace PaymentControllerGUI
{
    public class EmptyClass
    {
    }
}

and I'm trying this.

C:\Program Files (x86)\Microsoft Visual Studio 8\VC\bin>xsd /c /l:cs EmptyClass.cs

Error:

invalid command line argument: 'SubsystemReg.cs'

like image 942
user3264676 Avatar asked Feb 14 '23 14:02

user3264676


1 Answers

Using the XSD.exe, you should pass the DLL file path which your class is compiled in, instead of the CS class code file itself as you pass now.

For instance, if your class is compiled in SubsystemReg.dll, call XSD.exe like that:

XSD.exe C:\SubsystemReg.dll

Here is an example from MSDN:

The following command generates XML schemas for all types in the assembly myAssembly.dll and saves them as schema0.xsd in the current directory.

xsd myAssembly.dll  

UPDATE:

You can generate XSD from DLL for a specific type by specifying the fully-qualified path of the Type, for example:

xsd.exe YourAssembly.dll /type:YourNamespace.YourType

Per your case, just do:

xsd.exe PaymentControllerGUI.dll /type:PaymentControllerGUI.EmptyClass
like image 76
Yair Nevet Avatar answered Apr 27 '23 11:04

Yair Nevet