Automate xsd.exe during build

谁说胖子不能爱 提交于 2019-12-30 06:46:08

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/14897750/automate-xsd-exe-during-build

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!