Port xsd.exe to .NET Core
We use xsd.exe to generate C# classes based on xml schema. At present there is no xsd.exe tool to generate CoreCLR compliant code and hence code generation cannot be fully automated as part of the build at the moment.
Please let us know plan/timeline for availability of the same.
Related tracking issue for XmlSchema in CoreFX https://github.com/dotnet/corefx/issues/2342
/cc @piotrpMSFT @krwq @sepidehMS
The code XSD.exe generates is pretty much .NET Core safe, at least in my usage. What have you seen that's not usable?
@SamuelEnglard, AFAIK there are couple of attributes which do not exist on .NET Core which makes automating the tool harder.
@hrushib, currently I'd just add the missing attributes and treat them as no-ops so that your generated code compiles - it won't be ideal solution but should unblock you for now.
Our current plan is to bring XmlSchema back first and then proceed from there. Unfortunately I can't give you any specifics at this time :-( We currently did not have any prior requests for xsd.exe so we put it on our backlog. It's really valuable feedback to know that this is needed and being actively used as part of the build.
@krwq Very possible. I am using it as far as feedback that it's in use 😄
Now we have CodeDOM we do want to take a look at this for 1.2. Not immediately though.
@weshaggard if we did this, how would we ship the exe? would it have to go in the shared framework?
why not make it part of dotnet tooling?
@weshaggard if we did this, how would we ship the exe?
The majority of the tools are part of the SDK or CLI so I would expect it to ship in one of those 2 places.
I also need XmlCodeExporter to be ported to .net core (2.0). Any ETA or workaround for that? This is mostly what I use.
exporter.GetType().GetProperty
exporter.ExportTypeMapping
System.Xml.Serialization.XmlCodeExporter does not exist in .net core.
The milestone said future.
For people who been stuck 2 years and still counting. This might help but it's all in .NET framework, not .NET Core.
http://mikehadlow.blogspot.com/2007/01/writing-your-own-xsdexe.html https://github.com/codaxy/xsd2
Not sure if this is the right place for this comment, but I have a huge xsd-generated CS file (out of all of Amazon's XSDs). It compiles fine, but when I try to serialize an object using XmlSerializer then I get a PlatformNotSupportedException, saying it can't generate the temporary assemblies. This is on .NET Core 2.0. I bet something is up with the generated CS file, if I copy relevant parts out to a new file and use that then it works fine. Can it be due to the size of the classes, or what would trigger the XmlSerializer to try to build a temporary assembly?
I would like to be able to build a customizable XSD to C# converter, and looking at the latest recommendations, I should be using XsdDataContractImporter (together with XmlSchemaSet and CSharpCodeProvider), which is not available.
on Oct 11, 2016 Not immediately though.
Does it mean NEVER or sometime after 2029? Please SHIP the stuff if it isn't a rocket science and doesn't require more than few hours of work. Delaying this kind of petty stuff is only letting down folks who are actually using the product, "Not immediately" even from majority's use-case doesn't explain the intensity of of hundreds of other use-cases that are relying on xsd.exe.
Will it be a dontet-cli tool?
@weshaggard, @danmosemsft what is present recommendation for generating C# classes based on xml schema for CoreCLR projects built on Linux?
@hrushib I'm using https://github.com/mganss/XmlSchemaClassGenerator successfully.
@hrushib if you're doing it in automated way then we do not have any way to do that, if you're planning to generate and modify it by hand you can generate them on full framework on Windows and with minimal modification they should be usable.
@krwq, I am looking forward for automation as this is expected to happen with build. We are waiting for this support for almost couple of years now. Absence of this support is pushing us to use workaround of manual updation of this file using xsd.exe and checkin for builds triggered on Linux, as full framework tool can't be used there :(.
Can you provide plans/timelines for this feature to be available on CoreCLR?
dotnet-xscgen is released from https://github.com/mganss/XmlSchemaClassGenerator, you can reference it in your netcoreapp2.0 project:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<DotNetCliToolReference Include="dotnet-xscgen" Version="2.0.*" />
</ItemGroup>
</Project>
and then run it as dotnet xscgen --help in the project directory.
With dotnet 2.1's CLI, we will also be able to install it as standalone app (outside the project context): dotnet tool install dotnet-xscgen --tool-path MyTools then use it as MyTools/dotnet-xscgen.exe --help or dotnet tool install dotnet-xscgen --global and use it as dotnet xscgen --help.
@hrushib we currently do not have plans for xsd.exe
Does the dotnet-xscgen read in the C# model and validate the data dynamically inside the C# script instead?
If not then what DotNetCore component should I be looking for that does this with XML Schema Set, XmlReader, XmlReaderSetting, etc. stuff for this kind of XML Schema validation?