Library vs app .csproj, semantic versioning
Understand library vs app .csproj, how NuGet consumes libraries, and how semantic versioning (MAJOR.MINOR.PATCH) guides releases.
Library vs app .csproj, semantic versioning is a free C# Academy lesson on CoddyKit. This is lesson 1 of 3. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the C# Academy learning path, and your progress syncs across the web and the CoddyKit app. The C# Academy course includes 3 lessons in total.
Concepts & goals
Goal: Know when to create a library vs an app, and how versions signal change.
- Library .csproj: built to be referenced and packed for NuGet
- App .csproj: produces an executable for end users
- Semantic versioning: MAJOR.MINOR.PATCH
Library vs App: quick view
- Library: targets frameworks to maximize reuse; has metadata (PackageId, Version, Authors).
- App: has an entry point; publishes runnable output.
- NuGet packs libraries into .nupkg; apps are usually published, not packed.
Assembly version demo
A library exposes a version; consumers see it when they reference the package.
using System;
using System.Reflection;
// Simple demo: read the assembly version at runtime.
// In a packed library, this reflects the version consumers see.
public class Program
{
public static void Main(string[] args)
{
Version v = Assembly.GetExecutingAssembly().GetName().Version;
Console.WriteLine("Assembly version: " + (v == null ? "unknown" : v.ToString()));
}
}
SemVer compare (basic)
Compare versions to decide updates: MAJOR first, then MINOR, then PATCH.
using System;
// Minimal SemVer (MAJOR.MINOR.PATCH) parsing and comparison.
// Ignores prerelease/build metadata for simplicity (good enough for beginners).
public class SemVer : IComparable<SemVer>
{
public int Major;
public int Minor;
public int Patch;
public static bool TryParse(string s, out SemVer v)
{
v = null;
if (string.IsNullOrEmpty(s)) return false;
string[] parts = s.Split('.');
if (parts.Length < 3) return false;
int a, b, c;
if (!int.TryParse(parts[0], out a)) return false;
if (!int.TryParse(parts[1], out b)) return false;
if (!int.TryParse(parts[2], out c)) return false;
v = new SemVer { Major = a, Minor = b, Patch = c };
return true;
}
public int CompareTo(SemVer other)
{
if (other == null) return 1;
if (Major != other.Major) return Major.CompareTo(other.Major);
if (Minor != other.Minor) return Minor.CompareTo(other.Minor);
return Patch.CompareTo(other.Patch);
}
public override string ToString()
{
return Major + "." + Minor + "." + Patch;
}
}
public class Program
{
public static void Main(string[] args)
{
SemVer a, b;
if (SemVer.TryParse("1.4.2", out a) && SemVer.TryParse("1.5.0", out b))
{
int cmp = a.CompareTo(b);
Console.WriteLine(a + " vs " + b + " -> " + (cmp < 0 ? "older" : (cmp > 0 ? "newer" : "equal")));
}
}
}
Version bump rules
Bump rules:
- MAJOR: breaking API changes
- MINOR: new features, backward-compatible
- PATCH: bug fixes/chores, no API change
Tip: communicate changes in a short changelog.
Pre-pack checklist
- Library targets set (e.g., netstandard)
- PackageId, Version, Authors filled
- License/readme included
- Public API reviewed for breaks
SemVer rule
Recap
Recap: Build libraries for reuse and NuGet packing; apps are executables. Use MAJOR.MINOR.PATCH to communicate change safely.
Learn C# with an AI tutor — free
Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.
- Courses
- 93
- Lessons
- 346
Frequently Asked Questions
Is the “Library vs app .csproj, semantic versioning” lesson free?
Yes — the full text of “Library vs app .csproj, semantic versioning” is free to read here on the web. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the C# Academy course, upgrade to CoddyKit PRO. The C# Academy course includes 3 lessons in total.
What will I learn in “Library vs app .csproj, semantic versioning”?
Understand library vs app .csproj, how NuGet consumes libraries, and how semantic versioning (MAJOR.MINOR.PATCH) guides releases. You practise C# Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start C# Academy?
No prior experience is required. C# Academy on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 1 of 3.
How long does the “Library vs app .csproj, semantic versioning” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this C# Academy lesson?
Yes. Every C# Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Library vs app .csproj, semantic versioning
- Packing & publishing to NuGet
- Multi-targeting