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 project, as defined in the following list:
- Project template: Class Library/
classlib
- Project file and folder:
PacktLibraryNetStandard2
- Workspace/solution file and folder:
Chapter05
- Project template: Class Library/
- Open the
PacktLibraryNetStandard2.csproj
file, and note that, by default, class libraries created by the .NET SDK 7 target .NET 7 and, therefore, can only be referenced by other .NET 7-compatible assemblies, as shown...