Reputation: 7167
I need a way to automatically regenerate *.cs files during build, based on *.xsd files, preferably without involving any custom add-ins. This needs to run on the CI build as well.
I'm not sure if I'm missing something obvious, or is this really tricky as it seems to me?
Upvotes: 8
Views: 11421
Reputation: 13706
I use this script:
@echo off
cd %1
call :treeProcess %2 "XSDs"
cd ..
goto :eof
:treeProcess
rem From http://stackoverflow.com/a/8398621/298754
echo Processing %2
for %%f in (*.xsd) do call :buildXSD %%f %1 %2 %%~nf
for /D %%d in (*) do (
cd %%d
call :treeProcess %1 %2.%%d
cd ..
)
exit /b
:buildXSD
%2 %1 /c /n:%3.%4%
with a prebuild event of
call "$(ProjectDir)"XSDBuilder.bat "$(ProjectDir)"\XSDs "$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\@InstallationFolder)bin\xsd.exe"
This will recursively parse every .xsd file in a folder in the project root called XSDs
, and will assign a namespace based on the folder structure.
Upvotes: 8