Search code examples
c#.net-coregit-submodulesvisual-studio-2022

Visual Studio Pro 2022 add git submodule to solution


I am trying to use git submodules to manage shared code between two projects written in C#. I have tried the solutions from these questions with no luck:

Add git submodule as reference to existing solution in VS

How to add a GIT submodule for VSTS for use with Visual Studio 2017

Workflow for using git submodules in Visual Studio

I can add the submodule using git submodule add <url> followed by git submodule init and git recognizes it, but Visual Studio does not. Adding the .csproj file as an Existing Item in Visual Studio doesn't lead to it recognizing the classes in the submodule exist either. What can I do to make Visual Studio recognize the classes in the submodule?


Solution

  • You did everything right, you only have to add a reference to the new submodule in the project folder. To do this simply add a project in the submodule to your project folder. VS2022 should immediately show the submodule in the GIT view. If not, check if your VS2022 is up to date. The submodule feature came with one of the latest updates.