title: User secrets not available to .net core app hosted in windows service
body: <p>I am attempting to access user secrets in a .Net Core Windows Service.  The service itself is running under a service account, and I have added a user secret for the service user.</p>
  
  <p>When running the application as a straightforward console application, the user secret can be accessed.  However, when running the application as a windows service, the setting cannot be read.  There is no error - just the value is not obtained.  The service is running under the same user account as the logged in user - and the secret can be obtained when running the console application.</p>
  
  <p>When I add the secrets.json file to the hosted executable's location and read it in using the AddJsonFile method then the value can be read.  Here is a code snippet:</p>
  
  <pre><code>    public Startup(IHostingEnvironment env)
      {
          var builder = new ConfigurationBuilder()
              .SetBasePath(Directory.GetCurrentDirectory())
              .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
              .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
  
          builder.AddEnvironmentVariables();
  
          // does not work as a service
          builder.AddUserSecrets("TestUserSecrets");
  
          // works as a service when secrets.json is copied to exe directory
          // builder.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "Secrets.json"));
  
          Configuration = builder.Build();
  
          Log.Logger = new LoggerConfiguration()
              .ReadFrom.Configuration(Configuration)
              .CreateLogger();
      }
  
      public IConfigurationRoot Configuration { get; set; }
  
  
      public void Configure(IApplicationBuilder app, ILoggerFactory logFactory)
      {
          // attempt to obtain secret config value
          string secret = Configuration["Secret"];
  </code></pre>
  
  <p>Is there an issue with the windows service getting access to the user secret (in the secret.json file)?  </p>
  
  <p>Is the intention just to use user secrets for development, and therefore using user secrets in a windows service is just not going to work?</p>