Getting Started
Begin by creating a new .NET console app and setting an initial version:Program.cs and add a version field:
Semantic Versioning (Major.Minor.Patch)
Semantic Versioning (SemVer) uses a three-part format: MAJOR.MINOR.PATCH. It’s ideal for libraries and APIs where backward compatibility matters.- Major: Breaking changes
- Minor: New, backwards-compatible features
- Patch: Bug fixes and small enhancements
Follow semver.org guidelines to maintain consistency across releases.
1. Incrementing Major
When you introduce breaking changes:2. Incrementing Minor
For new, non-breaking features:3. Incrementing Patch
For bug fixes or tweaks:Real-World Workflow
- Fix a bug → Patch:
v1.2.1 - Add a feature → Minor:
v1.3.1 - Revamp API (breaking) → Major:
v2.0.0
- Clear upgrade path: patch/minor safe, major breaking
- Widely adopted by package managers (NuGet, npm)
- Communicates intent to consumers
Date-Based Versioning (YYYY.MM.DD.BUILD)
Date-Based Versioning encodes the release date and a daily build counter. It’s perfect for fast-paced CI/CD workflows.Example Builds
First build on October 3, 2024:Build counter resets daily. Useful for tracking exact deploy date in high-frequency releases.
- Immediate insight into release date
- Simplifies automated CI pipelines
- No ambiguity about build sequence
Comparing Versioning Strategies
| Strategy | Format | Use Case | Pros |
|---|---|---|---|
| Semantic Versioning | MAJOR.MINOR.PATCH | Libraries, APIs, traditional release cycles | Predictable compatibility, standard across ecosystems |
| Date-Based Versioning | YYYY.MM.DD.BUILD | Rapid CI/CD, daily deployments | Clear date tracking, easy automation |
Choosing Your Strategy
-
Semantic Versioning
Ideal for API-driven products and packages where compatibility communication is critical. -
Date-Based Versioning
Best for teams with continuous deployment, where the exact release date and order matter more than change scope.