🕵️ SicherheitslückenHak5: Hackers Just Poisoned the Rust Supply Chain | Threat Wire(01.09.2026 um 14:00 Uhr)
🕵️ SicherheitslückenHak5: Hackers Found a Way Into Humanoid Robots | Threat Wire(04.09.2026 um 15:04 Uhr)
🔧 AI Nachrichten Bits und so #1021 (Passwort für Laufwerk)(31.08.2026 um 22:15 Uhr)
🔧 AI Nachrichten Bits und so #1022 (Wie Weißbier)(06.09.2026 um 20:39 Uhr)
🍏 iOS / Mac OSHue-App 6.0 ist da: das sind die Neuerungen(07.09.2026 um 17:21 Uhr)
🕵️ SicherheitslückenHak5: Hackers Just Poisoned the Rust Supply Chain | Threat Wire(01.09.2026 um 14:00 Uhr)
🕵️ SicherheitslückenHak5: Hackers Found a Way Into Humanoid Robots | Threat Wire(04.09.2026 um 15:04 Uhr)
🔧 AI Nachrichten Bits und so #1021 (Passwort für Laufwerk)(31.08.2026 um 22:15 Uhr)
🔧 AI Nachrichten Bits und so #1022 (Wie Weißbier)(06.09.2026 um 20:39 Uhr)
🍏 iOS / Mac OSHue-App 6.0 ist da: das sind die Neuerungen(07.09.2026 um 17:21 Uhr)

🔧 Programmierung 🕛 vor 1 Jahr 4 Min Lesezeit
0

Semantic Versioning for .NET Core apps and assemblies

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht




Introduction



I frequently need to set a (this is a



Checking that the version reported from HTTP services (web apps ,APIs) is correct is a crucial part of my CD pipelines and is one of the (smoke) tests I use to determine if the deployment succeeded.



In this post Ill show you how to stamp a semver version number on a .NET assembly - i.e. an .exe or .dll compiled using a .NET compiler - during build, then read it at run time.






So many version numbers



As Andrew Locks (free) or



In the screenshot above, Product version is the caption for InformationalVersion whereas File version is the caption for FIleVersion.



Of the four types of version numbers described above, only the first three apply to any assembly (i.e. whether or not the assembly is part of a Nuget package).



Of those three, AssemblyVersion alsways adds a 0 in the fourth place if you try to set a semver version which only has three numbers (plus an optional prerelease suffix). For example if you try to set a semver version of 1.0.2-beta during build and then read the AssemblyVersion value at run time in the assembly, it would be 1.0.2.0.



FileVersion does the same, as shown in the screenshot above.



InformationalVersion is the only version number which would get set exactly to the server version we set during build (as screenshot above shows).



Therefore, InformationalVersion is the version that should be read at run time.






Set a SemVer version number




  1. In a <PropertyGroup> element in the projects csproj file, add element <IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion> :


  2. Pass the version number as value of Version parameter of dotnet build e.g.:







Reading an assemblys SemVer version at run time



Code that reads InfromationalVersion at run time is as follows:




CODE
string? version = Assembly.GetEntryAssembly()?. GetCustomAttribute<AssemblyInformationalVersionAttribute>()?. InformationalVersion;






In my minimal APIs, to add a /version endpoint as I showed in Inroduction section above, I place the above snippet in Program.cs, before builder.Build() is called, then add the following snippet immediately after:




CODE
//this object of an anonymous type will //be serialised as JSON in response body//when returned by a handlervar objVersion = new { Version = version ?? "" };//OTHER CODE//var app = builder.Build()






After builder.Build() is called, I create the handler for /version endpoint:




CODE
app.MapGet("/version", () => objVersion);






Now when I run the API project and call the /version endpoint, I get the version number back in a JSON object in HTTP response body:




CODE
{ "version": "1.0.2-beta"}


Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Hackers Just Poisoned the Rust Supply Chain | Threat Wire
1 Quelle
Hackers Found a Way Into Humanoid Robots | Threat Wire
1 Quelle
Bits und so #1021 (Passwort für Laufwerk)
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Semantic Versioning for .NET Core apps and assemblies

Thematisch verwandte Begriffe: Semantic, Versioning, Core, apps · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...