title: User Configuration Settings in .NET Core
body: <p>I spent all day yesterday researching this and cannot find any reasonable solution.</p>
  
  <p>I'm porting a .NET Framework project to .NET Core 2.0. The project used user settings (<code>Properties.Settings.Default</code>) to store certain information that persisted through each application launch. It could also update this information (e.g. user preference options).</p>
  
  <p>My understanding is that is does not exist in .NET Core? So how is it possible to achieve this? The closest thing I could find was installing a few NuGet packages and using <code>Microsoft.Extensions.Configuration</code>, however, this is not even close to <code>Properties.Settings.Default</code> in the .NET Framework.</p>
  
  <p>First, it requires a file (JSON, XML, what have you) to be in the running file's directory. This seems insane, especially in the case of secure information. In addition, I don't want to push a config file with the project when internal libraries of my project should be able to handle all of it, as it did with .NET Framework.</p>
  
  <p>I realize there are Environment Variables, but I cannot get them to load in for the life of me. It honestly should be a simple process so I'm not sure if I'm missing something blatantly obvious. Here, in the Properties>Debug section of my library, there is a section called "Environment variables" which I have added two values in.</p>
  
  <p><a href="https://i.stack.imgur.com/kRD1l.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kRD1l.png" alt="Environment Variable Example"></a></p>
  
  <p>My configuration object looks like so:</p>
  
  <pre><code>private static IConfiguration Configuration { get; } = new ConfigurationBuilder()
      //.SetBasePath(Directory.GetCurrentDirectory())
      //.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
      .AddEnvironmentVariables()
      .Build();
  </code></pre>
  
  <p>To access the variables, I have tried these ways:</p>
  
  <pre><code>Configuration.GetSection("SettingName").Value;
  Configuration["SettingName"];
  Environment.GetEnvironmentVariable("SettingName");
  </code></pre>
  
  <p>They all return empty.</p>
  
  <p>Also, is there no way to save a property? I understand it was designed to be light weight, but surely there is a way to save?</p>
  
  <p>I've tried:</p>
  
  <pre><code>Configuration["SettingName"] = "Value";
  Environment.SetEnvironmentVariable("SettingName", "Value");
  </code></pre>
  
  <p>It seems to update the memory, but not the file itself, which leaves persistant settings useless.</p>
  
  <p>How can I read and save user settings in a library, while having it all contained within that library?</p>