添加 git 子模块作为对 VS 中现有解决方案的引用

Add git submodule as reference to existing solution in VS

假设我有子模块回购:

_git/DbModel (only source code indexed. No /bin or /obj folders)

以及两个需要 DbModel 作为参考库的项目:

_git/TTT
_git/TPM

我已经通过 GitBash 将 DbModel 作为子模块添加到它们中

 git submodule add https://RepoPath/_git/DbModel

我的本地存储库现在看起来像这样:

Source\Repos\TTT\TTT.sln
Source\Repos\TTT\DbModel\DbModel.sln

Source\Repos\TPM\TPM.sln
Source\Repos\TPM\DbModel\DbModel.sln

我的团队资源管理器显示了两种不同的解决方案,现在可以使用,我可以轻松地在它们之间切换。

但是。也许这是个新手问题...

我不知道如何添加 DbModel 解决方案作为对 TPM 和 TTT 的参考! 当我在 VS 中单击 "Add Reference" -> "Browse" 时,我只能添加“.dll、.tlb、.olb、.ocx、.exe、.manifest”作为“参考文件。

它应该如何工作?我是否应该每次都编译子模块解决方案并添加 .dll 作为参考?我需要添加源代码。

对于那些对此感兴趣的人:

git submodule add https://RepoPath/_git/DbModel
git submodule init   //this is IMPORTANT
git submodule update

然后从新创建的文件夹中将现有项目添加到您的解决方案中。像那样:

 Source\Repos\TPM\DbModel\DbModel\DbModel.csproj

P.S。

Source\Repos\TPM\                  solution root folder (with main project sln file inside it)
Source\Repos\TPM\DbModel           submodule root folder (with submodule sln file)
Source\Repos\TPM\DbModel\DbModel   submodule project folder (with csproj file)