首页 > 解决方案 > How to manage absolute file path in visual studio project in source control?

问题描述

I am hosting a source control git repo with a visual studio c++ project. It uses additional library directories and additional include directories in the .vcxproj file. I decided that I have two options:

1). Remove the .vcxproj file from source control, and only upload the files which contain source code.

2). Upload the .vcxproj file including my include and lib directories, and just live with the repo being polluted.

I noticed that there is a .vcxproj.user file which has specific user details, but I don't know if it's possible to store file paths there. I wonder if there is a way to store absolute file paths like the include and library directories in a file other than the .vcxproj file.

标签: gitvisual-studioversion-control

解决方案


.vcxproj文件对于 C++ 项目是必需的,因此我建议您保留.vcproject源代码控制并将库移动到您的源代码中(如您提到的选项 2)。

而且它不会污染您的 git 存储库,因为您可以将文件管理到 git 存储库中的子文件夹中并使用新路径添加引用。

我注意到有一个具有特定用户详细信息的 .vcxproj.user 文件,但我不知道是否可以在其中存储文件路径。

.vcxproj.user文件仅用于用户指定的信息,不应将其添加到 git repo 中。您可以将文件导入.gitginore. 这是一个.gitignore适合 VS 项目的例子。

我想知道是否有一种方法可以将绝对文件路径(如包含和库目录)存储在 .vcxproj 文件以外的文件中。

不,没有办法将 git repo 目录之外的文件存储到 git repo 中。即使您可以使用库目录中的引用,但是当有人将您的 git 存储库克隆到另一台机器时,将找不到引用。

此外,如果您愿意将这些库管理到一个单独的 git 存储库中,您可以将这些库添加为当前存储库的git 子模块


推荐阅读