Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DotNet Core - Purpose of Solution Files

Tags:

c#

.net-core

What's the purpose of using solution files for DotNet Core projects? I'm using a Mac, and I can use project-to-project reference to modularize and build shared libraries without solution files:

dotnet add reference ..\Library\Library.csproj

which adds the following to my current directory's .csproj file:

<ItemGroup>
  <ProjectReference Include="..\Library\Library.csproj" />
</ItemGroup>

And now building my current directory's .csproj will build Library.csproj.

like image 692
azizj Avatar asked Apr 15 '17 14:04

azizj


1 Answers

Solution file works as container for application's project/projects. It comes handy when you are working on your application out of IDE. Following are some of uses of solution file.

  1. Open project or multiple projects in IDE just by opening solution file in IDE. e.g. If you open solution file in visual studio then all of projects which are part of solution will get opened in visual studio.
  2. You can control build/deployment of projects (what to build and what not to) under solution using solution level configuration.
  3. If you are using editor like VS Code then solution file facilitate to build all those project which are part of solution just by running "dotnet build" command. If projects were not part of solution then you need to build them individually.
  4. When working out of IDE (like Visual Studio) and source control you can add all project files and solution to source control just by adding solution to source control. Same goes with check in or checkout.

These are some of advantages of solution file and there can be many more. However solution file is not must have thing and you can still live without it. Its just makes developer's life easy and improves productivity.

like image 180
Pankaj Kapare Avatar answered Oct 13 '22 19:10

Pankaj Kapare