1

A common structure seen on most projects on GitHub is the following. A good example is Json.Net repository. I want to achieve the same thing using Visual Studio 2019:

MyProject
├── Doc
│   ├── txt/md/... files
├── Src
│   ├── .sln
│        ├── Project1 (eg. netstandard lib)
│        └── Project2 (eg. tests)
├── .gitignore
├── LICENSE.md
└── Readme.md

Similar questions on SO (1, 2) move the "projects" into a folder not the "solution". Note that in this structure, the solution is also inside the "Src" folder.

I've adapted some of the suggestions such as switching to folder view and that way I successfully move the entire .sln and project folders into 'src' folder but the problem is that Visual Studio creates a new solution at root. And the final structure becomes this:

MyProject
├── Doc
│   ├── txt/md/... files
├── Src
│   ├── .sln 
│        ├── Project1 (eg. netstandard lib)
│        └── Project2 (eg. tests)
├── .gitignore
├── LICENSE.md
├── Readme.md
└── Extra_solution.sln <-- this is the problem

The red circled solution in below screenshot was created as soon as I opened the moved solution:

screenshot

Dale K
  • 25,246
  • 15
  • 42
  • 71

1 Answers1

1

So the structure you want is common, as outlined by David Fowler here: https://gist.github.com/davidfowl/ed7564297c61fe9ab814. Note that the .sln file is at the root, and I find this to be far more common.

What I do when creating it in Visual Studio is unload the project (via a right-click on the project), then move it, then re-add the project to the solution.

There's another way, and that is to do everything via the command line:

mkdir MyProject
cd MyProject
dotnet new sln
dotnet new classlib -o src/Project1
dotnet new mstest -o src/Project2
dotnet sln add src/Project1
dotnet sln add src/Project2
Rob Johnston
  • 859
  • 8
  • 21