Building class libraries
Class library assemblies group types together into easily deployable units (DLL files). Apart from when you learned about unit testing, you have only created console applications to contain your code. To make the code that you write reusable across multiple projects, you should put it in class library assemblies, just like Microsoft does.
Creating a class library
The first task is to create a reusable .NET class library:
- In your existing
Code
folder, create a folder namedChapter05
, with a subfolder namedPacktLibrary
. - In Visual Studio Code, navigate to File | Save Workspace As…, enter the name
Chapter05
, select theChapter05
folder, and click Save. - Navigate to File | Add Folder to Workspace…, select the PacktLibrary folder, and click Add.
- In TERMINAL, enter the following command:
dotnet new classlib
. - Open the
PacktLibrary.csproj
file, and note that by default class libraries target .NET 5 and therefore...