title: .NET Core 2 Service Fabric console apps common configuration file
body: <p>I'm trying to build out a bunch of stateful microservices written in .NET Core 2.1.  These are <em>not</em> ASP.NET applications, no http interface, but rather designed as console apps that are consuming messages off a service bus.</p>
  
  <p>I'm having a deuce of a time trying to figure out how to reference my appsettings.json file into the service packages.  There's a bunch of articles related to using the appsettings.json file in an ASP.NET service fabric app (basically spelling it out in a webhost builder) but that's not applicable for me, since I'm not using ASP.NET.</p>
  
  <p>I have a single appsettings.json file that all the microservices in this application should be able to use.</p>
  
  <p>I also found this article <a href="https://stackoverflow.com/questions/37278074/service-fabric-include-additional-files">Service Fabric include additional files</a> which talks about putting it into an sfproj target for MSBuild, but there seems to be no information whatsoever about what the file structure looks like on the target end.</p>
  
  <p>What I tried to do is add targets to my sfproj file like so:</p>
  
  <pre><code>&lt;Target Name="AfterPackage" AfterTargets="Package"&gt;
      &lt;Copy SourceFiles="appsettings.json" DestinationFolder="$(PackageLocation)\appsettings.json" /&gt;
  &lt;/Target&gt;
  </code></pre>
  
  <p>and then in my service, I'd try to instantiate an <code>IConfiguration</code> object based upon <code>..\appsettings.json</code> but as one might guess by now, the service, upon attempting to publish, throws a FileNotFoundException looking for the appsettings.json file, so clearly the file is in a different location relative to the micro service.  (Of course, the publish failure just says there was a problem and rolls back, you have to dig into the the SF Explorer to actually see that message)</p>
  
  <p>What should this configuration look like?  I can't find any documentation describing what the file system of a stateful microservice looks like, I'm not clear on where I should be putting this common file, or how the services should be accessing the file.  Some help would be appreciated.</p>