在 Visual Studio C++ 中将源文件存储在项目文件目录之外2009年

发布于 2024-08-18 05:46:30 字数 619 浏览 2 评论 0原文

Visual Studio 项目假定属于该项目的所有文件都位于与项目文件相同的目录中,或者位于其下的目录中。

对于特定项目(在非 Visual Studio 意义上),这不是我想要的。我想将 MSVC 特定的文件存储在另一个文件夹中,因为可能还有其他方法来构建应用程序,例如使用 SCons。此外,MSVC 生成的所有内容都会使源目录变得混乱。

示例:

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

我可以在资源管理器中手动将文件添加到 source 目录,然后在 Visual Studio 中将它们与项目链接。这不是世界末日,但 Visual Studio 试图规定我的项目的文件夹结构让我有点恼火。

我正在查看项目文件的架构,但意识到这很烦人假设是在 IDE 中而不是项目文件的格式。

有人知道比从 source 目录手动将文件链接到项目更简洁的方法来解决这个问题吗?

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 tries 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暮光沉寂 2024-08-25 05:46:30

我有时会使用它,非常确定这就是您想要的:

  • 确保解决方案资源管理器中的显示所有文件选项已打开。
  • 创建一个针对您的源目录的符号链接,并将该链接放在与您的项目相同的级别,如果您想要更好的控制,甚至可以放在更低的级别。命令是 mklink /j target source

对于您显示的示例项目结构,您将运行 mklink /msvc/source /source 并且在项目中源目录将显示就像它在项目目录中一样(好吧,实际上是这样)。额外的好处:通过 VS 添加新项目也会自动将它们放入正确的目录中。

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.

起风了 2024-08-25 05:46:30

您可以添加带有这样的链接的文件,它们是可搜索的、可查看的,但如果您尝试更改它们,它们不会签出,并且 Visual Studio 也会将通配符保留在适当的位置:

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

这位于 .proj 文件内。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文