Storing source files outside of a project file in Visual Studio C ++ 2009

Visual Studio projects assume that all files belonging to the project are located in the same directory as the project file, or one below it.

For a specific project (in the sense of not Visual Studio) this is not what I want. I want to store MSVC-dependent files in a different folder, because there may be other ways to create an application, for example, using SCons. In addition, all the materials that MSVC reveals clutter the source directory.

Example:

/source /scons /msvc <- here is where I want my MSVC-specific stuff 

I can add the files in Explorer to the source directory manually, and then associate them in Visual Studio with the project. It's not the end of the world, but it annoys me a bit that Visual Studio is trying to dictate the folder structure of my project.

I looked at the schemas for the project files, but realized that this annoying assumption is in the IDE, not in the project file format.

Does anyone know an easier way to solve this problem than manually linking files to a project from the source directory?

+6
visual-c ++ visual-studio directory-structure
source share
2 answers

I use this sometimes, pretty sure what you want:

  • make sure Show All Files enabled in your solution explorer.
  • create a symbolic link aimed at your source directory and place the link at the same level as your project, or even lower if you want finer control. mklink /j target source

For an example of the project structure that you are showing, you run mklink /msvc/source /source , and in the project the source directory will appear as if it were in the project directory (well, actually it is). An added bonus: adding new items through VS also automatically places them in the correct directory.

+3
source share

You can add files with links like this, they are searchable, viewable, but they are not checked if you try to change them, and the visual studio leaves wildcards:

  <ItemGroup> <Content Include="..\Database Schema\Views\*.sql"> <Link>Views\*.sql</Link> </Content> </ItemGroup> 

This is included in the .proj file.

+3
source share

All Articles