Advanced Software Learning Paths
Efficient Code Sharing in C# .NET Using Class Libraries and NuGet Packages
This course is intended to improve improving your code sharing and modularization skills. It covers the essentials of creating C# class libraries, working with NuGet packages, and leveraging private NuGet feeds hosted on GitHub. The focus is on enhancing collaboration, maintainability, and reusability by adopting best practices and streamlined approaches.
Course Details
Target Audience: Intermediate C# .NET Programmers
Duration: 3 Days (3 hours per day, 1 hour per session)
Prerequisites
Intermediate knowledge of C# programming: Participants should have a good understanding of C# syntax, basic programming constructs, and experience with creating and working on C# projects.
Familiarity with .NET Core/.NET 5 or later: Participants should have experience working with .NET Core or later versions, including project structure, dependencies, and configuration.
Basic understanding of Git and GitHub: Participants should know how to use Git for version control, including cloning repositories, committing changes, pushing and pulling code, and resolving conflicts. They should also be familiar with GitHub features like creating and managing repositories, branching, and pull requests.
Experience with an IDE: Participants should be comfortable using an IDE (ex Visual Studio, VS Code, Jetbrains Rider, etc.) for C# development, including creating projects, navigating the IDE, debugging, and managing NuGet packages.
Familiarity with object-oriented programming (OOP) concepts: Participants should understand basic OOP concepts such as inheritance, encapsulation, polymorphism, and abstraction, and be able to apply them in their C# code. (see 10.5 Programming Concepts Library)
Basic understanding of software architecture and design patterns: While not strictly required, having some knowledge of software architecture principles and common design patterns can help participants better understand the motivations behind code sharing and modularization.
Course Material
Session 1: Class Library Essentials (1 hour + practice)
Session 2: Introduction to NuGet (1 hour + practice)
Install and Use a NuGet Package with Visual Studio | NuGet 101 \[2 of5\]
Install and Use a NuGet Package with the .NET CLI | NuGet 101 \[3 of 5\]
Create and Publish a NuGet Package with Visual Studio | NuGet 101 \[4 of 5\]
Create and Publish a NuGet Package with the .NET CLI | NuGet 101 \[5 of 5\]
Recap: Creating and Publishing a NuGet Package - DEVOPS (C#/.NET)
This video is useful as it shows how to specify properties in .csproj files
We will need to publish to a private NuGet feed.
How to create a NuGet package targeting multiple frameworks...
Our API is written in .NET 6 and the automations software is in .NET Framework v4.8.1, so we need to target multiple frameworks for our project. This will require some manual setup.
Note that it is better to use .NET standard instead of targeting multiple frameworks
Session 3: Creating Custom NuGet Packages (1 hour + practice)
Deploy NuGet Packages w/ GitHub Actions (Automatic Versioning)
Trigger a GitHub Actions workflow when a folder changes
We want to set it up so that the GitHub Action only runs when the NuGet package gets updated - we don't want to increase the version of the package if nothing has changed with it.
This article also mentions how to target when files change. You may be able to target specific files if the folder filter is not specific enough.