There is nothing that prevents you from having multiple projects within a single instance of Visual Studio Code. The default project structure for ASP.NET Core projects actually makes use of multiple folders. You can see that structure in action in all the ASP.NET Core projects on GitHub, e.g. the MVC one:
─ src
├─ Microsoft.AspNetCore.Mvc
├─ Microsoft.AspNetCore.Mvc.Abstractions
├─ Microsoft.AspNetCore.Mvc.Core
└─ Microsoft.AspNetCore.Mvc.Razor
─ test
├─ Microsoft.AspNetCore.Mvc.Abstractions.Test
├─ Microsoft.AspNetCore.Mvc.Core.Test
├─ Microsoft.AspNetCore.Mvc.Razor.Test
└─ Microsoft.AspNetCore.Mvc.Test
Each of those is a folder with a full independent project, with its own project.json
that defines the project and sets up dependencies.
Unfortunately, the Yeoman integration in VS Code does not seem to allow scaffolding projects into subfolders. So what you need to do is create the src
and test
folder yourself, scaffold your projects individually and move them into the appropriate folder. For example, I started creating an “Empty Web Application” with the name Example
, and then created a “Unit test project (xUnit.net)” with the name Example.Test
. Then, I simply dragged Example
into the src
folder, and Example.Test
into test
.
So the root of the project, and as such the folder you open with VS Code, and where you would initialize your repository, is the directory where those src
and test
folders live in. For example, my project (set up with Git and vscode specific configs) would now look like this:
─ .git
─ .vscode
─ src
└─ Example
─ test
└─ Example.Test
─ global.json
─ README.md
The benefit of this structure is actually that it’s also compatible with what Visual Studio would do when you create a new solution.