Local packaging and versioning
Local packaging and versioning
A NuGet package is a distributable archive containing metadata and assets. Packing a library creates a local .nupkg; publishing transfers it to a package source. Package versions communicate compatibility intent and participate in dependency resolution, but they do not prove compatibility. Keep package creation, inspection and publication separate.
Proposed baseline: .NET SDK 10.0.404, net10.0 / C# 14. All results are reasoned, not executed. Build and test examples require an approved isolated environment. Framework examples are separate test classes, not console entry points.
Set library package metadata
In the local Rates lab, package metadata lives in the library project. The ID is synthetic and for local use only.
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net10.0</TargetFramework> <Nullable>enable</Nullable> <ImplicitUsings>disable</ImplicitUsings> <PackageId>ByteMind.Sample.Rates.Local</PackageId> <Version>1.2.0</Version> <Authors>ByteMind example</Authors> <Description>Local shipping fee teaching fixture.</Description> </PropertyGroup></Project>Version may also affect assembly and informational version defaults. PackageVersion, AssemblyVersion and FileVersion can be controlled independently; do not assume equality or change assembly identity casually.
Expected observation (reasoned, not executed):
A successful pack produces ByteMind.Sample.Rates.Local.1.2.0.nupkg.Create a local artifact
Use the included reviewed local lab and SDK; these commands are not executed here. Restore must be successful before --no-restore.
dotnet restore Rates/Rates.csproj --configfile NuGet.Configdotnet pack Rates/Rates.csproj -c Release --no-restore -o artifactsPack may compile; it is not push. Inspect the archive with a local ZIP viewer before sharing it. Look for its .nuspec, framework-specific library assembly and intended metadata. Exact auxiliary files vary with SDK options.
Expected observation (reasoned, not executed):
Expected package: artifacts/ByteMind.Sample.Rates.Local.1.2.0.nupkg, if build and pack succeed.Compare versions before selecting a release
Use a package version override to plan a prerelease artifact without editing the source project. No external publication.
dotnet pack Rates/Rates.csproj -c Release --no-restore -p:PackageVersion=1.3.0-beta.1 -o artifactsA prerelease sorts below the corresponding stable 1.3.0. Semantic versioning convention uses major for breaking API changes, minor for compatible additions, patch for compatible fixes. Verify public API compatibility rather than relying on the label. Keep archives local; no registry credentials or uploads.
Expected observation (reasoned, not executed):
Expected package: artifacts/ByteMind.Sample.Rates.Local.1.3.0-beta.1.nupkg.Common mistakes and edge cases
A build succeeds before publication but consumers may still have missing compatible assets or license constraints. Inspect package contents for secrets, unrelated files and required notices; do not publish from this lesson. Do not confuse a package version with the SDK or runtime version, and do not overwrite immutable published artifacts.
Practice and recap
Plan a local package for a compatible bug fix after 1.2.0. Name its expected file and explain which artifacts must be checked before release.
Hint: Use the patch component and keep the package ID unchanged.
Learning objective: Describe the contents of a local package. See accompanying manual practice and knowledge check.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Local packaging and versioning — knowledge check
Apply the lesson concepts to the following scenarios.
What does dotnet pack create?
Which version conventionally indicates a compatible bug fix after 1.2.0?
Which version sorts before stable 1.3.0?
What should be inspected in a package?
Why is successful pack not sufficient for release?