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 or .NET Interactive notebooks 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:
- Use your preferred coding tool to create a new class library, as defined in the following list:
- Project template: Class Library /
classlib
- Workspace/solution file and folder:
Chapter05
- Project file and folder:
PacktLibrary
- Project template: Class Library /
- Open the
PacktLibrary.csproj
file, and note that by default class libraries target .NET 6 and therefore can only work with other .NET 6-compatible assemblies, as shown in the following markup:<Project Sdk="...