2
我得出一个小的宏脚本从Visual Studio Macro to Format all Files in a Solution但遗憾的是它并没有使用XML,XAML,工作配置等所有ProjectItem
是基于XML的通常抛出异常(命令不可用),当他们在他们的主要观点vsViewKindPrimary
被打开:Visual Studio宏:如何格式化xml文件?
Dim projectItem As ProjectItem ' actually this is a parameter of a sub'
Dim window As Window = projectItem.Open(Constants.vsViewKindPrimary)
window.Activate()
projectItem.Document.DTE.ExecuteCommand("Edit.FormatDocument")
window.Close(vsSaveChanges.vsSaveChangesYes) ' actually this is part of a finally block'
结果:
System.Runtime.InteropServices.COMException (0x80004005): Command "Edit.FormatDocument" is not available.
at EnvDTE.DTEClass.ExecuteCommand(String CommandName, String CommandArgs)
当与他们保持原样vsViewKindTextView
打开它们作为文本,虽然Edit.FormatDocument
可以执行。
是否还有其他命令必须用于xml文件?代码有问题吗?
请添加任何德语信息的英文翻译,因为这主要是英语问题和答案。谢谢 – 2011-08-09 10:53:06