title: How to configure self-contained single-file program?
body: <p>I am experimenting with <code>.Net Core 3</code> trimmed single-file publishing creating a simple console application and using this to publish:</p>
  
  <pre><code>dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true
  </code></pre>
  
  <p>Configuration is done with the standard <code>appsettings.json</code> and <code>ConfigurationBuilder</code> from <code>Microsoft.Extensions.Configuration.Json</code>.</p>
  
  <p>The problem is the config file is packaged with the whole app and so is unavailable - it can be accessed in the temp dir created when running the program but that is not very useful for a regular user.</p>
  
  <p>I found out that you can exclude files from the packaging process by editing the csproj file or with a custom publishing profile </p>
  
  <pre><code>&lt;ItemGroup&gt;
      &lt;None Update="appsettings.json"&gt;
        &lt;CopyToPublishDirectory&gt;PreserveNewest&lt;/CopyToPublishDirectory&gt;
        &lt;ExcludeFromSingleFile&gt;true&lt;/ExcludeFromSingleFile&gt;
      &lt;/None&gt;
  &lt;/ItemGroup&gt;
  </code></pre>
  
  <p>This does output the appsettings file in the publish dir however it is not used when running the application - an empty config file is created and used instead. Is there any way to do this "properly" since documentation is kinda lacking on the issue or should I just manually parse the file I expect to be in the starting directory (which itself was a hassle to find because <code>Assembly.Get###Assembly</code> were all returning the temp dir)?</p>