开发者

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

开发者 https://www.devze.com 2022-12-17 01:30 出处:网络
Visual Studio projects assumes all files belonging to the project are situated in the same directory as the project file, or one underneath it.

Visual Studio projects assumes all files belonging to the project are situated in the same directory as the project file, or one underneath it.

For a particular project (in the non-Visual Studio sense) this is not what I want. I want to store the MSVC-specific files in another folder, because there might be other ways to build the application as well, for example with SCons. Also all the stuff MSVC splurts out clutters 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 link them in Visual Studio with the project. It's not the end of the world, but it annoys me a bit that Visual Studio tr开发者_Go百科ies to dictate the folder structure of my project.

I was looking through the schemas for the project files but realized that this annoying assumption is in the IDE and not the format of the project files.

Do someone know a neater way to solve this than manually linking files to the project from the source directory?


I use this sometimes, pretty sure it's what you want:

  • make sure the Show All Files option is on in your solution explorer.
  • create a symlink that targets your source directory and put the link at the same level as your project, or even lower if you want finer control. The command is mklink /j target source

For the example project structure you show, you'd run mklink /msvc/source /source and in the project the source directory will show up as if it was in the project dir (well, actually it is). Additional bonus: adding new items through VS also automatically puts them in the right directory.


You can add files with links like this, they are searchable, view-able, but they do not checkout if you try to change them, also visual studio leaves the wildcards in place:

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

This goes inside the .proj file.

0

精彩评论

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

关注公众号