I have repo A and repo B, they're in different folders, but repo A uses a namespace from repo B, how would I make this connection in Visual Studio 2022? Is there a way, other than including all files in the same project?
CodePudding user response:
First, you need to include the project (.csproj) from repo B in the Solution (.sln) of repo A. Then, in the project from repo A, you need to add a project reference to project B.
To do this, follow these steps:
- In the Solution that contains the project from repo A, right click on the Solution and choose Add --> Existing Project
- Navigate to the folder where your .csproj of repo B exists and select the .csproj, then hit OK
- In your Solution, in project A right click on Dependencies and select "Add Project Reference"
- Select project B
Now, your project from repo A references the project from repo B and can use its APIs.
That's the simple way. The drawback is that this will only work locally, because it depends on the folder setup and the relative paths of the projects from the different repos.
You could also try submodules if you work with Git as described here: Add git submodule as reference to existing solution in VS