7

我需要一种在构建过程中根据 *.xsd 文件自动重新生成 *.cs 文件的方法,最好不涉及任何自定义加载项。这也需要在 CI 构建上运行。

我不确定我是否遗漏了一些明显的东西,或者在我看来这真的很棘手吗?

4

1 回答 1

8

我使用这个脚本:

@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%

与预建事件

call "$(ProjectDir)"XSDBuilder.bat "$(ProjectDir)"\XSDs "$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\@InstallationFolder)bin\xsd.exe"

这将递归解析项目根目录中名为 .xsd 的文件夹中的每个 .xsd 文件XSDs,并将根据文件夹结构分配命名空间。

于 2013-02-15T15:43:43.953 回答