NuGet, Packaging and Deployment
47.1 NuGet Packages
In Visual Studio: Manage NuGet Packages (right-click the project) or the Package Manager Console: Install-Package Dapper.
Creating a package: set <PackageId>, <Version>, <Authors>, <Description> in the .vbproj, then run dotnet pack -c Release.
dotnet add package Newtonsoft.Json
dotnet add package Microsoft.Data.SqlClient --version 5.2.0
dotnet list package --outdated
dotnet remove package Newtonsoft.Json47.2 Building and Publishing
Small. Requires the .NET runtime installed.
Includes the runtime. Larger, but has no prerequisites.
Easy install and auto-update for WinForms/WPF (Publish wizard)
Modern Windows packaging (Store or sideload) WiX Toolset, Inno Setup, Advanced Installer, InstallShield Copy the publish folder
dotnet build -c Release
dotnet publish -c Release -r win-x64 --self-contained false # framework-dependent
dotnet publish -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true # single EXE with the runtime
dotnet publish -c Release -r win-x64 -p:PublishReadyToRun=true # faster startup47.3 Configuration and Versioning
appsettings.json + Microsoft.Extensions.Configuration, App.config + My.Settings (desktop), environment variables, command-line arguments.
Assembly versioning: <Version>, <AssemblyVersion>, <FileVersion>, semantic versioning, My.Application.Info.Version at runtime.
Code signing executables and installers (Authenticode) to avoid SmartScreen warnings.
47.4 CI/CD
GitHub Actions / Azure DevOps pipelines: dotnet restore → dotnet build → dotnet test → dotnet publish → artifact/release. Windows runners are needed for WinForms/WPF.