問題描述
我正在運(yùn)行 Visual Studio 2010.我有一個(gè) XSD
架構(gòu)并希望使用 xsd.exe 工具生成適當(dāng)?shù)?C# 文件.我已經(jīng)從命令行成功完成了這項(xiàng)工作,但現(xiàn)在我想從 IDE 執(zhí)行同樣的操作.
I am running Visual Studio 2010. I have a XSD
schema and want to use xsd.exe tool to generate appropriate C# file. I have done this successfully from a command line but now I want to do the same from IDE.
是否有一些眾所周知的路線?我設(shè)法使用了預(yù)構(gòu)建事件,但我討厭在每個(gè)構(gòu)建上運(yùn)行該工具.通常,它應(yīng)該只在 XSD 更改時(shí)運(yùn)行.
Is there some well-known route for this? I have managed to use a pre-build event but I hate to have the tool running on each build. Normally, it should only run when XSD changes.
將生成的 .cs 文件添加到項(xiàng)目中,將其放在同名的 .xsd 下,以便 IDE 知道它們是相關(guān)的.
Adding the generated .cs file to project puts it under .xsd of the same name, so the IDE knows they are related.
我知道我可以在我的 .xsd 上設(shè)置自定義工具",但我不確定這是否能達(dá)到預(yù)期的效果.我希望有更直接的方法.
I know I can set "Custom Tool" on my .xsd but I am not sure if that achieves the desired effect. I was hoping for a more straightforward way.
最終,VS2010 無法執(zhí)行 XSD.EXE,因?yàn)樗挥?SDK 文件夾中,而 VS 已知的路徑顯然不包含它.
And ultimately, VS2010 cannot execute XSD.EXE because it lives in the SDK folder and the path known to VS obviously does not include it.
歡迎提出任何建議!
推薦答案
您可以查看 Xsd2Code 以獲得 VS以交互方式執(zhí)行此操作的插件.據(jù)我所知,作者也在開發(fā)一個(gè)VS2010版本.
You can check out Xsd2Code for a VS addin that does this interactively. The author is also working on a VS2010 version, as far as I know.
替代文本 http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=Xsd2Code&DownloadId=41336
這篇關(guān)于在 Visual Studio IDE 中從 XSD 自動(dòng)生成 C#的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!