Mash.AppSettings.DevSettings
1.2.0
dotnet add package Mash.AppSettings.DevSettings --version 1.2.0
NuGet\Install-Package Mash.AppSettings.DevSettings -Version 1.2.0
<PackageReference Include="Mash.AppSettings.DevSettings" Version="1.2.0" />
paket add Mash.AppSettings.DevSettings --version 1.2.0
#r "nuget: Mash.AppSettings.DevSettings, 1.2.0"
// Install Mash.AppSettings.DevSettings as a Cake Addin #addin nuget:?package=Mash.AppSettings.DevSettings&version=1.2.0 // Install Mash.AppSettings.DevSettings as a Cake Tool #tool nuget:?package=Mash.AppSettings.DevSettings&version=1.2.0
Mash.AppSettings.DevSettings
New support in Mash.AppSettings allows for an override setting loader for developer-specific values. Maybe you want a different connection string to an Azure storage account, instrumentation key for Application Insights, or service endpoint. When each developer can specify their own options, you can quickly debug locally without having to keep files checked out with your changes, careful not to accidentally commit them.
Dev setting file
The developer-specific files must be in JSON format, and need only specify app settings you wish to override.
Your code can do a check to see if it is in dev mode (perhaps based on an environment variable). Ideally, each developer in the team can commit their own file to the project using their unique user name to make the files unique that way the call to construct DevSettingLoader will not need to be different per user.
{
"Setting1": "DevOverride",
"ConnectionStrings": {
"Cxn1": "DevOverrideCxn"
}
}
Override settings loading
To override settings loading, simply assign a DevSettingsLoader to AppSettingsLoader. I like to choose to do mine in Debug builds only.
private static void Main(string[] args)
{
LoadDevSettings();
// load/access settings
Console.WriteLine(Settings.Instance.Setting1);
}
[System.Diagnostics.Conditional("DEBUG")]
private static void LoadDevSettings()
{
// find the project directory
var currentDir = Directory.GetCurrentDirectory();
int binDirIndex = currentDir.LastIndexOf("\\bin");
var devSettingsDir = currentDir.Remove(binDirIndex);
// put all developer override files in a subfolder named DevSettings
devSettingsDir = Path.Combine(devSettingsDir, "DevSettings");
// fileName null to use the logged in user
var devSettingLoader = new DevSettingLoader(devSettingsDir, fileName: null);
// assigning the loader to this property makes the magic work
AppSettingsLoader.DevSettings = devSettingLoader;
}
Developer support
Useful information will be traced during loading. Watch your output window for any issues encountered.
What's New
December 6, 2018
Converted project to target .NET Core 2.1.
November 28, 2016
Initial implementation.
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. |
.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 is compatible. |
.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
- Mash.AppSettings (>= 1.2.0)
- Microsoft.CSharp (>= 4.7.0)
- System.Text.Json (>= 4.7.1)
-
.NETStandard 2.1
- Mash.AppSettings (>= 1.2.0)
- Microsoft.CSharp (>= 4.7.0)
- System.Text.Json (>= 4.7.1)
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.2.0 | 6,214 | 3/8/2020 |
1.1.1 | 1,469 | 12/17/2018 |
1.0.6179.30210 | 5,494 | 12/2/2016 |
1.0.6176.29434 | 1,406 | 11/29/2016 |
Target net standard. Replace Newtonsoft.Json with System.Text.Json.