# Solutions and Project References — .NET Core: Build, Test and Ship Web APIs

Source: https://www.geekswithgeeks.com/en/dotnet-core/proj-solutions

> Organise an API, a class library and tests into one solution.

## One solution, many projects

A solution file lets you build and test several projects together. A project reference makes one project use another's code, for example the API using a shared `Core` library.

## Wire it together

Create three projects, group them in a solution and reference the library from the API and the tests.

```bash
dotnet new sln -n Shop
dotnet new classlib -o src/Shop.Core
dotnet new web -o src/Shop.Api
dotnet new xunit -o tests/Shop.Tests
dotnet sln add src/Shop.Core src/Shop.Api tests/Shop.Tests
dotnet add src/Shop.Api reference src/Shop.Core
dotnet add tests/Shop.Tests reference src/Shop.Core
```

## Avoid circular references

Project A cannot reference B if B already references A. If you hit this, move the shared code into a third, lower-level project.

**Quiz:** What does `dotnet sln add` do?

- [ ] Adds a NuGet package
- [x] Adds a project to the solution file
- [ ] Publishes the solution
- [ ] Adds a database

*Answer:* Adds a project to the solution file. It registers existing projects in the `.sln` so they build together.
