Common.Config
1.0.6
dotnet add package Common.Config --version 1.0.6
NuGet\Install-Package Common.Config -Version 1.0.6
<PackageReference Include="Common.Config" Version="1.0.6" />
<PackageVersion Include="Common.Config" Version="1.0.6" />
<PackageReference Include="Common.Config" />
paket add Common.Config --version 1.0.6
#r "nuget: Common.Config, 1.0.6"
#:package Common.Config@1.0.6
#addin nuget:?package=Common.Config&version=1.0.6
#tool nuget:?package=Common.Config&version=1.0.6
⚙️ Common.Config
A shared configuration library for desktop apps that supports per-application settings, ClickOnce-safe storage, and default config seeding from embedded JSON.
✅ Features
✔ Per-app configuration using %AppData%
✔ Strongly typed config class support
✔ Multi-class support in a single config file
✔ Loads defaults from embedded .defaults.json
✔ Safe across ClickOnce updates
✔ Uses System.Text.Json
✔ Fully DI-compatible with generic AppSettingsService<T>
📦 Installation
Install via your internal NuGet feed:
dotnet add package Common.Config --version 1.0.x
✅ Usage in Code
1. Register Config Service in Startup
// Register multiple classes if needed:
services.AddAppSettings<RefboxConfig>("RefboxManager", key: "RefboxConfig");
services.AddAppSettings<NetworkOptions>("RefboxManager", key: "NetworkOptions");
🧠 The softwareName
controls the config path at:
%AppData%\OptonMedia\<SoftwareName>\settings.json
2. Define Your Settings Models
public class RefboxConfig
{
public string ReferenceBoxName { get; set; }
public int RetryAttempts { get; set; }
}
public class NetworkOptions
{
public string Hostname { get; set; }
public int Port { get; set; }
}
3. Inject and Use Them
public class MyViewModel
{
private readonly AppSettingsService<RefboxConfig> _refboxSettings;
public MyViewModel(AppSettingsService<RefboxConfig> refboxSettings)
{
_refboxSettings = refboxSettings;
}
public void Update()
{
_refboxSettings.Settings.ReferenceBoxName = "WD999";
_refboxSettings.Save();
}
}
🧾 Example Embedded Default Config
File: RefboxManager.defaults.json
(Build Action: Embedded Resource)
{
"RefboxConfig": {
"ReferenceBoxName": "WD191",
"RetryAttempts": 3
},
"NetworkOptions": {
"Hostname": "localhost",
"Port": 8080
}
}
📂 Config File Locations
Purpose | Location |
---|---|
Default config | Embedded as <SoftwareName>.defaults.json in your app |
Runtime settings | %AppData%\OptonMedia\<SoftwareName>\settings.json |
🧠 Behavior
- On first launch:
- If no config file exists, loads defaults from embedded
.defaults.json
- Then saves them to
%AppData%
- If no config file exists, loads defaults from embedded
- On future launches:
- Always reads updated values from
%AppData%
- Always reads updated values from
✅ Good Practices
- Do not hardcode defaults in your model classes
- Do not manually modify
%AppData%
JSON files - Each app must pass a unique
softwareName
toAddAppSettings<T>
- Always call
Save()
to persist changes
🚫 Limitations
- JSON comments (
//
,/* */
) are not supported - No built-in schema validation
📌 Example Apps
RefboxManager
HPWLSBurnInTest
WeldMasterConfigTool
Each uses this shared NuGet package with its own .defaults.json
and config model.
📦 Folder Structure
/Common.Config
/IAppSettingsProvider.cs
/JsonAppSettingsProvider.cs
/AppSettingsService.cs
/ConfigServiceExtensions.cs
✅ Future Features
- 🔐 Encrypted fields for secrets
- 🧪 Config validation helpers
- 💾 Backup/restore APIs
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.7)
- System.Text.Json (>= 9.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.6 | 175 | 8/8/2025 |