问题描述
我正在运行 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#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!