How to create a blank solution without a folder

Visual Studio

3 years ago

You may know the drill – create a GitHub repo, clone it, fire up Visual Studio to create a blank solution.

Let's create a blank solution here

Let's create a blank solution here

Unfortunately, Visual Studio does not put the .sln file into the selected location. Instead, it creates a nested folder with the same name:

And hence, a nested path is born!

And hence, a nested path is born!

VS 2017 had a checkbox that allowed us to specify not to create a folder, but that is missing in the new dialog. So how to work around this?

Simple fix

A simple workaround is to change the Location to a folder above the cloned folder – so instead of C:\Dev\MyCoolProject\ we use C:\Dev\. Simple but effective and efficient!

Dotnet CLI

For more flexibility, we can use the .NET Core CLI's dotnet new command. Launch command line from the cloned folder and type:

This will generate a blank solution file with the same name as the current folder. Furthermore, to give the .sln a custom name, we can use the -n option: