views:

39

answers:

1

In my team, we put all our projects (only 7 large ones) in the same solution. And since some code is common between project we tend to have the same file included in each project. This is fine and compiles/runs well. But when I do a global search in my solution, VS does a "stupid" search and goes through all the files in each project, without checking if a file has already been searched.

This leads to longer searches whose results have duplicates. Do anyone know a fix for this issue?

+3  A: 

Why not put everything that's common to all projects in a project of its own, and link all the project against it? Shared functionality should be shared, not duplicated.

Allon Guralnek
-1: the code is shared, but it's shared at the file level rather than the project level. nothing wrong with that.
Vicky
+1, Allon is correct. Should be a shared project not adding the same file to multiple projects.
Paolo
OK, can you explain why you think that's a better way of doing it? Suppose I have one solution which contains two projects, each of which implements a tool that deals with my particular variety of USB-connected device. It seems quite reasonable to me to put common code (eg for enumerating the connected devices) in one file which is compiled into both projects.
Vicky
@Vicky, for one thing, this results in compiling those shared files twice, so both projects will have duplicate object code. Perhaps the linker will optimize that, probably not. It also results in the OP's problem, which is why we're having this discussion in the first place. The OP asked for a fix to the problem, not if what he was doing was wrong.
Nick Meyer
@Nick: Thanks for your explanation. I understand the OP's problem, but I still think it's fundamentally a bug / unwanted behaviour in VS rather than an issue in the way he's set up his solution. He can work around the unwanted behaviour by configuring the solution as suggested but that doesn't make that configuration "better" in any other way, as you and others seem to be saying. If I have ProjA (build output a.exe) and ProjB (build output b.exe) which both depend on foo.c, how is that "less good" than ProjFoo (output foo.lib) which both ProjA and ProjB depend on?
Vicky
@Vicky: I think I just gave a very good reason. Regardless, whether this layout is better or not is a separate question. The answer solves the OP's problem -- downvoting it because you don't like that particular style of layout seems a bit harsh.
Nick Meyer