在VS中添加git子模块作为现有解决方案的引用[英] Add git submodule as reference to existing solution in VS

本文是小编为大家收集整理的关于在VS中添加git子模块作为现有解决方案的引用的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

可以说我有一个supdule repo:

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

和两个需要dbmodel作为参考库的项目:

_git/TTT
_git/TPM

我已经通过gitbash添加了dbmodel作为subpodule

 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的引用! 当我单击"添加参考" - >"浏览"时,我只能添加" .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)

本文地址:https://www.itbaoku.cn/post/2450774.html

问题描述

Lets say I have a submodule repo:

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

And two projects which need DbModel as reference library:

_git/TTT
_git/TPM

I've already added DbModel as submodule via GitBash to both of them

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

And my local repos now look like this:

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

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

My Team Explorer shows two different solutions which are available now and I can switch between them easily.

But. Maybe this is a kinda newbie question...

I don't know how to add DbModel solution as reference to TPM and TTT! When I click "Add Reference" -> "Browse" in VS I can only add ".dll, .tlb, .olb, .ocx, .exe, .manifest" as "reference files.

How is it supposed to work? Should I compile sub module solution every time and add .dll as reference? I need source code to be added.

推荐答案

For those who will be interested in this:

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

and then add existing project in your solution from newly created folder. Like that:

 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)