开发者

Put files automatically in /scripts folder in Visual Studio 2005

I set up a bunch of filters in my project to help find files. But all my source code files actually just go in two folders, source/headers... the filters are just for Visual Studio organization but I wanted to keep the directory structure simple for building in other compilers.

Anyway, whenever I add a new item or class, the files go in my /scripts folder and I have to move them. Is there a project-specific way to change this, I'm sic开发者_开发知识库k of having to do it!?


When you right-click on a filter and choose Properties, a window opens on the right of the screens. You will have a field named Filter, which contains the extensions supported by the current filter (example for include : h;hpp;hxx;hm;inl;inc)

Maybe your Scripts filter has a problem on this side.


There is no such option that would do everything automatically for you. However, when adding a new item, you can right-click on the desired filter, choose Add -> New Item. In the dialog that opens you can change the path where the file will be created. After confirming the dialog, you will have the file both in the correct filter and in the correct folder.


It is not possible out of the box in visual studio 2005.

Things like this, the power of being independent from the project system and it's version change for each new release, opening the possibility to cross-platform building are all reasons I switched to CMake to generate programmatically the projects and solutions of my project. We harvest what we have on disk and all the filters in the projects are re-created based on what is on disk.

Haven't looked back.

Of course, this is another tool with a learning curve, but bringing a scripting engine to the build environment opens a whole lot of opportunities.


could you please clarify: do you have a scripts folder or scripts filter? VS should place new files in the Header Files/Source Files filter by default, does this happen?

You might be able to automate moving your files using Macros:

DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate()
DTE.ActiveWindow.Object.GetItem("{original filename including filter}").Select(vsUISelectionType.vsUISelectionTypeSelect)
DTE.ExecuteCommand("Edit.Cut")
DTE.ActiveWindow.Object.GetItem({target filter}).Select(vsUISelectionType.vsUISelectionTypeSelect)
DTE.ExecuteCommand("Edit.Paste")

Code like this could be executed whenever files are added: How to: Handle Events by Using Macros

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜