ApplicationSettingsFSharp 1.1.0

dotnet add package ApplicationSettingsFSharp --version 1.1.0
                    
NuGet\Install-Package ApplicationSettingsFSharp -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ApplicationSettingsFSharp" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ApplicationSettingsFSharp" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="ApplicationSettingsFSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ApplicationSettingsFSharp --version 1.1.0
                    
#r "nuget: ApplicationSettingsFSharp, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ApplicationSettingsFSharp@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ApplicationSettingsFSharp&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=ApplicationSettingsFSharp&version=1.1.0
                    
Install as a Cake Tool

This project allows for simple reading and writing of configuration files on a json file.

Example usage:

Create file called AppConfig.json, in it place the following:

  {
    "DbUsername": "SomeDefaultUsername",
    "DbPassword": "SomeDefaultPassword",
    "ConnectionString": {
      "Database": "Host=SomeAddress.com;Port=5432"
    }
  }

Make sure the file is copied to the output directory

<Content Include="AppConfig.json">
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

Afterwards set up the following:

module SomeApp.AppSettings

open Config.Net

//This sets up the interface declaring the types of the json file and their read/write access
//For more information and additional options see https://github.com/aloneguid/config
type SettingsInterface =
  [<Option(DefaultValue = "")>]
  abstract DbUsername: string with get, set

  [<Option(DefaultValue = "")>]
  abstract DbPassword: string with get, set

  [<Option(Alias = "ConnectionString.Database")>]
  abstract ConnectionStringDatabase: string with get, set
  
//This creates the file with the name SomeAppSettingsFileName in the folder "AppConfig" "C:\Users\SomeUser\Something\ApplicationFolder", and gives access to those settings.
let settings () = ApplicationSettingsFSharp.Configuration.Settings<SettingsInterface> "AppConfig" "C:\Users\SomeUser\Something\ApplicationFolder" "SomeAppSettingsFileName"

Finally use it like so:


open SomeApp.AppSettings

//Reading settings
let settings = settings()

let dbUsername = settings.DbUsername
let dbPassword = settings.DbPassword
let connectionString = settings.ConnectionStringDatabase

//Writing settings
let settings = settings()

settings.DbUsername <- "Some New Username"
settings.DbPassword <- "Some New Password"
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1.0 103 8/20/2026
1.0.0 782 1/9/2021