Search code examples
c#.net-corexsd.net-core-2.2

Cannot Generate XSD file from .Net Core 2.2 Class


I am trying to convert a .NET Core (2.2) class to an xsd file. The class is simple

[GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[SerializableAttribute()]
public class Core_Class
{
    public int ID { get; set; }
}

Everytime i try to run xsd.exe to create an xsd file for my class on the .net core class I get the following error

Error: There was an error processing 'C:\Users\....\repos\.....\.....\bin\Debug\netcoreapp2.2\.....dll'.
  - Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

If I run the same command with xsd.exe in a standard .net framework 4.6 project the xsd file is generated correctly. Is there any way I can generate an xsd file from a .net core class??


Solution

  • After searching around and not finding an answer to this question I ended up with a workaround instead of a solution. I had to convert my .NET core libraries to .NET Standard 2.0 class libraries. Converting to .NET standard libraries allows both .NET core and .NET framework (4.6+) to reference them. After this xsd.exe worked as expected.