Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: msbuild task for automatic source generation #7

Open
2 tasks
fubar-coder opened this issue Jan 8, 2017 · 6 comments
Open
2 tasks

Suggestion: msbuild task for automatic source generation #7

fubar-coder opened this issue Jan 8, 2017 · 6 comments

Comments

@fubar-coder
Copy link
Contributor

It would be nice to have a MSBuild task that creates the source code of an XSD file automatically. The following features for xsd2 would be needed:

  • Automatically detect and load includes and imports
  • Avoid duplicated processing of XSD types and elements

How should the msbuild task be configured?

@mstijak
Copy link
Member

mstijak commented Jan 8, 2017

I usually invoke xsd2 from a pre-build step. If xsd files change, code is updated on the next build. That worked very well for me.

@fubar-coder
Copy link
Contributor Author

The reason for this suggestion is, that I wanted to avoid recreation of the xsd2 output when the source file(s) didn't change to avoid unnecessary recompilation. This - just as issue #6 - is of quite low priority for me. The xsd2 tool is already usable as-is.

@mstijak
Copy link
Member

mstijak commented Jan 8, 2017

That could be another flag. Skip the run if the output file is newer than the latest xsd input.

@meirkr
Copy link
Contributor

meirkr commented May 25, 2020

Maybe the following PR will answer your need.
#13

Maybe it's not perfect, but I saw in most cases, it doesn't call to xsd2 generation until file change or rebuild was requested.

I've added to rthe readme an example how should the lines in the csproj file (I guess it will be the same in msbuild file as well - the should be the same afterall...).

P.S
Pay attention that I also upgraded there the .net framework (maybe I'll add .Net core support and upgrade to vs2019 one day...) as well as trasforming the csproj to the new .NET SDK format for better files and nugets management.

@fubar-coder
Copy link
Contributor Author

This does look better. It's just confusing that you might end up having a dependency for a C# source file that might not exist.

@meirkr
Copy link
Contributor

meirkr commented May 31, 2020

I don't understand your point.
If the c# source doesn't exist, it will know to create the command line.
If it exists and nothing was changed, since you just call build again, it won't call the command line.
This is how it is done at least in visual studio configuring csproj to do this magic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants