本文介绍了如何格式化在Visual Studio 2012中的所有文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与Visual Studio的早期版本,我用格式在我的解决方案,所有的C#文件。

With previous versions of Visual Studio, I used Kevin Pilch-Bisson's script to format all C# files in my solution.

VS2012下降的宏观支持,所以不能正常工作了。

VS2012 dropped macro support, so that doesn't work any more.

我怎么能轻易格式化我的所有文件在VS2012?

How can I easily format all my documents in VS2012?

推荐答案

打开工具 - > 库包管理器 - > 软件包管理器控制台,并运行以下命令。最后,所有的文件将在IDE中打开。 (低-RAM的机器将有大的解决方案。)修改过的文件将是
在IDE修改,并且不被保存到磁盘。您可以保存所有,然后关闭所有,如果你准备好了。

Open ->->, and run the command below. At the end, all documents will be open in the IDE. (Low-RAM machines will have problems with large solutions.) Changed files will bemodified in the IDE, and not saved to disk. You can Save All, then Close All if you're ready.

VS2012去掉,在以前的版本
的Visual Studio中存在的VB般的宏语言。然而,底层的DTE接口仍然存在,而你
可以通过PowerShell的实现它,在Package Manager控制台

VS2012 removed the VB-like macro language that existed in previous version ofVisual Studio. However, the underlying DTE interface is still there, and youcan reach it via PowerShell, in the Package Manager Console

怪异的GUID传递到的

function f($projectItems) { $projectItems | ? { $_.Name.EndsWith( ".cs" ) } | % { $win = $_.Open('{7651A701-06E5-11D1-8EBD-00A0C90F26EA}') ; $win.Activate() ; $DTE.ExecuteCommand('Edit.FormatDocument') } ; if ($projectItems) { $projectItems | % { f($_.projectItems) } } }

$dte.Solution.Projects | % { f($_.ProjectItems) }

这篇关于如何格式化在Visual Studio 2012中的所有文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 11:46
查看更多