The .NET CLI, you might be surprised to learn, is so fully featured and flexible that I find it orders of magnitude faster to use than an IDE for creating, manipulating, and setting up .NET projects and solutions.

Suppose we want to set up a project as follows:

projectSetup

The first order of business is to create a directory to hold the solution and project files.

mkdir CancellableTests

This will create an empty directory, which we immediately switch to.

cd CancellableTests

newDirectory

From here, we create a class library project to store our logic.

dotnet new classlib -o Logic

addLogic

We then want a xUnit3 test project. Note that this is xUnit version 3, which is an overhaul of version 2.

dotnet new xunit3 -o Tests

addtests

If you get an error about missing templates, install them as follows:

dotnet new install xunit.v3.templates::3.2.2

Next, we create a blank solution.

dotnet new sln

newSolution

To reduce noise when it comes to source control, we typically want a .gitignore in the root directory.

dotnet new gitignore

newGitignore

The directory structure should look like this:

cancelFileSystem

Finally, we add our projects to our solution.

Typically, you’d do it like this:

dotnet sln add Logic/

And then immediately:

dotnet sln add Tests/

You can do this in a single command:

dotnet sln add Logic/ Tests/

slnAddMultiple

You can verify all is well by listing the projects in the solution.

dotnet sln list

cancelSolutionList

This, undoubtedly, will also work for F# and VB.NET projects.

TLDR

You can add multiple projects to a solution in a single command.

Happy hacking!