UpdateMethods
Reusable update logic with OS-based routing: Windows, Proxmox, NixOS.
public static class UpdateMethods
1. Methods
1.1. CompareSemVer(string, string)
Version compare tailored to NETSetup release tags. Returns <0 when a is older than b, 0 when equal, >0 when newer.
Rules:
-
Compare the numeric core (
major.minor.patch[.build]) via . -
If the core matches and either side has no pre-release, the stable version wins (e.g.
1.0.0 > 1.0.0-x) per SemVer 2.0. -
If both have a pre-release, ignore the channel label entirely and compare the numeric tail after the last dot (the GitVersion build counter, e.g.
249in0.9.0-proxmoxvms.249). This way a branch rename in CI doesn’t trick the comparator into thinking a higher counter is older. -
Fallback: ordinal compare of the full pre-release tail when no trailing number can be parsed on either side.
public static int CompareSemVer(string a, string b)
| Name | Type | Description |
|---|---|---|
a |
string |
|
b |
string |
Returns: int
1.2. DecryptReleaseToken()
Decrypts the embedded GitHub Releases PAT just-in-time. Plaintext lives only on the returned string for the lifetime of one self-update cycle — never stored in a field.
public static string DecryptReleaseToken()
Returns: string
1.3. DetermineUpdateStage(ISystemHost)
Determines which update stage should execute based on the host’s operating system.
public static UpdateMethods.UpdateStage DetermineUpdateStage(ISystemHost host)
| Name | Type | Description |
|---|---|---|
host |
ISystemHost |
Returns: UpdateMethods.UpdateStage
1.4. GetLocalSemVer()
Returns the running NETSetup binary’s SemVer with any GitVersion build-metadata suffix (+<sha>) stripped, so it can be compared against the release tag which is the bare SemVer (e.g. 0.9.0-proxmoxvms.249).
public static string GetLocalSemVer()
Returns: string
1.5. ParseReleaseInfo(string, string)
Pure parser for the GitHub Releases API /repos/.../releases/latest response. Strips the leading v from tag_name, locates the asset whose name equals assetName, and returns both. Throws JsonException on malformed input or missing tag_name.
public static UpdateMethods.ReleaseInfo ParseReleaseInfo(string releasesLatestJson, string assetName)
| Name | Type | Description |
|---|---|---|
releasesLatestJson |
string |
|
assetName |
string |
Returns: UpdateMethods.ReleaseInfo
1.6. RunUpdate(ISystemHost, IServiceProvider, NETSetupConfig, bool, bool)
Runs the update cycle for the detected OS.
public static void RunUpdate(ISystemHost host, IServiceProvider services, NETSetupConfig config, bool skipOsUpdates = false, bool skipChocoPackages = false)
| Name | Type | Description |
|---|---|---|
host |
ISystemHost |
|
services |
IServiceProvider |
|
config |
NETSetupConfig |
|
skipOsUpdates |
bool |
|
skipChocoPackages |
bool |