在Visual Studio IDE中从XSD自动生成C# [英] Automatically generate C# from XSD in Visual Studio IDE

查看:73
本文介绍了在Visual Studio IDE中从XSD自动生成C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行Visual Studio2010.我有一个 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.

欢迎提出任何建议!

推荐答案

对于VS,您可以签出 Xsd2Code 以交互方式执行此操作的插件.据我所知,作者还在研究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#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆