visual-studio 编写 Visual Studio IDE 脚本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42643/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Scripting the Visual Studio IDE
提问by Matt Bishop
I'd like to create a script that will configure the Visual Studio IDE the way I like it. Nothing vastly complicated, just a few Tools/Options settings, adding some External Tools, that kind of thing.
我想创建一个脚本,以我喜欢的方式配置 Visual Studio IDE。没有什么特别复杂的,只是一些工具/选项设置,添加一些外部工具,诸如此类。
I know that this can be done inside VS with Import/Export Settings, but I'd like to be able to automate it from outside of VS. Is this possible, and if so, how?
我知道这可以通过导入/导出设置在 VS 内部完成,但我希望能够从 VS 外部自动化它。这可能吗,如果可以,怎么做?
Edited to add: doing it from outsideof VS is important to me -- I'm hoping to use this as part of a more general "configure this newly-Ghosted PC just the way I like it" script.
编辑添加:从VS外部执行它对我来说很重要 - 我希望将其用作更通用的“按照我喜欢的方式配置这台新的 Ghosted PC”脚本的一部分。
Edited again: the solution seems to be to hack CurrentSettings.vssettings, or use AutoIt. Details below.
再次编辑:解决方案似乎是破解 CurrentSettings.vssettings,或使用AutoIt。详情如下。
采纳答案by Matt Bishop
Answering my own question, in two ways:
以两种方式回答我自己的问题:
In VS2005/8, the things I mentioned (Tools/Options, External Tools) are all stored in the CurrentSettings.vssettings file, in the folder "Visual Studio 200{5|8}\Settings". This file is just XML, and it can be edited programmatically by anything that knows how to parse XML. You can also just paste a new vssettings file over the top of the default one (at least, this works for me).
The larger question of configuring a virgin PC. It turns out that not everything I want to change has an API, so I need some way of pretending to be a user who is actually sitting there clicking on things. The best approach to this seems to be AutoIt, whose scripting language I will now have to learn in my Copious Free Time.
在VS2005/8中,我提到的东西(工具/选项,外部工具)都存储在CurrentSettings.vssettings文件中,在“Visual Studio 200{5|8}\Settings”文件夹中。该文件只是 XML,任何知道如何解析 XML 的人都可以通过编程方式对其进行编辑。您也可以将一个新的 vssettings 文件粘贴到默认文件的顶部(至少,这对我有用)。
配置原始 PC 的更大问题。事实证明,并非我想要更改的所有内容都有 API,因此我需要某种方式来假装是实际坐在那里点击事物的用户。最好的方法似乎是AutoIt,我现在必须在我大量的空闲时间学习它的脚本语言。
回答by Mark Cidade
An easy way is to use the macro recorder to do something simple, then look at the code it produces and edit it as you see fit.
一个简单的方法是使用宏记录器做一些简单的事情,然后查看它生成的代码并根据需要进行编辑。
回答by David Sykes
On my machine Visual Studio stores it's local settings in a file called VCComponents.dat. Its a text file, so perhaps you could find a way of placing your settings directly in there.
在我的机器上,Visual Studio 将它的本地设置存储在一个名为 VCComponents.dat 的文件中。它是一个文本文件,所以也许您可以找到一种直接将设置放入其中的方法。
The file is stored in my users local AppData\Local\Microsoft\VC folder
该文件存储在我的用户本地 AppData\Local\Microsoft\VC 文件夹中

