問題描述
我正在運行 Visual Studio 2010.我有一個 XSD
架構并希望使用 xsd.exe 工具生成適當的 C# 文件.我已經從命令行成功完成了這項工作,但現在我想從 IDE 執行同樣的操作.
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.
是否有一些眾所周知的路線?我設法使用了預構建事件,但我討厭在每個構建上運行該工具.通常,它應該只在 XSD 更改時運行.
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 文件添加到項目中,將其放在同名的 .xsd 下,以便 IDE 知道它們是相關的.
Adding the generated .cs file to project puts it under .xsd of the same name, so the IDE knows they are related.
我知道我可以在我的 .xsd 上設置自定義工具",但我不確定這是否能達到預期的效果.我希望有更直接的方法.
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 無法執行 XSD.EXE,因為它位于 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以交互方式執行此操作的插件.據我所知,作者也在開發一個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
這篇關于在 Visual Studio IDE 中從 XSD 自動生成 C#的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!