pouët.net

Go to bottom

visual studio project organization

category: code [glöplog]
 
I'm having trouble figuring out a sane way of organizing my project in Visual Studio.

Basically, I'd like the files of my project to be organized into an arbitrarily deep directory hierarchy. This is how I work in netbeans and other some other IDEs, but those IDEs are not so good for developing windows applications. In these other IDEs, I can either add files and folders in the project explorer, and they appear on disk in the same way, or I can add files directly to the file system (e.g. by an update from the repository), and they'll just appear in the project explorer.

But when I try that in Visual Studio, it seems I need to simulate a directory hierarchy by creating "filters" and putting things in there. Which means I need to create each folder twice, and keep the two locations in sync, which is really annoying, especially if I want to move an existing file.

There are also two big problems: First, if I update from the repository, I have to figure out which new files there are and insert them into the project, or I have to keep the project in the repository, which suppose I could do, but I'd rather not. Second, if I have the same filename in two different directories (which happens from time to time, unless I purposely use an unnatural name to avoid a collision), VC wants to compile both of those files to the same .obj, which causes weird problems that are not always easy to figure out, and which causes me to have to manually specify a different .obj output.

So basically, what's a good way to avoid these problems? Am I really supposed to just have all of my files in the same directory, or use multiple projects (which only lets me have a hierarchy with a depth of 2, and requires me to set up multiple projects, which is annoying), and should I be committing the vc project file? (I've been putting project files outside of the repo since a lot of them are binary and can't be diffed).

Some advice/guidance/opinions would be welcome. Thanks!
added on the 2012-04-16 02:23:54 by yesso yesso
There's an option called Show All Files, that might help.
added on the 2012-04-16 06:34:22 by Gargaj Gargaj
It couldn't be that easy... Show All Files just shows all files that were manually added to your project and shoves them all at the top level (i.e. it's like disabling filters).

Thanks for answering, though.
added on the 2012-04-17 05:08:04 by yesso yesso
BB Image Gargaj, fixed that for you.
added on the 2012-04-17 14:54:11 by xTr1m xTr1m
xTr1m- oh, I get it. My source files were not below my .vcxproj file, so I got much different behaviour when I tried "show all files". Your .vcxproj files are in D:\Code\Blu64k\src\BluDX11 ?

Come to think of it, I'm not sure how I expected it to know where my source files were. I'm used to specifying where the source files are and where the project file gets saved in two separate steps when creating the project.

Well, thanks for the help!
added on the 2012-04-18 05:39:04 by yesso yesso
In Visual Studio, for C# projects, files are related to their structure on disk (even the default action for "delete" is deleting the file from disk), if you move files or folders around they get moved on disk aswell (with no need to necessarily show all files, just those added to the project).

Not sure if there's such an option for C++ projects, but there should be.
added on the 2012-04-18 14:44:08 by Jcl Jcl
yesso: Yes, the project file for the BluDX11 project is in D:\Code\Blu64k\src\BluDX11. All my projects are under a "src" Folder. My solution file is in D:\Code\Blu64k. I created that folder structure by moving the vcxproj files in explorer and editing the .sln file with notepad. It's cumbersome, but in the end most comfortable to work with from within visual studio.
added on the 2012-04-20 21:09:05 by xTr1m xTr1m
Jcl, nop, it sucks bottoms. It works excellent in C#, and when you use the exact same IDE (even inside the same solution), you get the filters nonsense. I guess it's for backward compatibility or something. Quite annoying indeed!
added on the 2012-04-20 21:18:36 by skrebbel skrebbel
skrebbel, I kinda have vague memories of having such a pain when I started doing C# from C++... but then again, that was around 2002 and I haven't ever looked back.

I have for the most part forgot all C++ sorrows :-)
added on the 2012-04-23 07:36:22 by Jcl Jcl

login

Go to top