How to publish environment specific appsettings in .Net core app?
<p>I have 3 environment specific <code>appsettings</code> files in my .Net core application</p>

<p><a href="https://i.stack.imgur.com/oAMuK.png" rel="noreferrer"><img src="https://i.stack.imgur.com/oAMuK.png" alt="enter image description here"></a></p>

<p>in <code>project.json</code> I have setup <code>publishOptions</code> like this. ( based on suggestion <a href="https://stackoverflow.com/questions/37858312/dotnet-publish-doesn%C2%B4t-publish-correct-appsettings-env-environmentname-json/37859691">here</a>)</p>

<pre><code>"publishOptions": {
    "include": [
      "wwwroot",      
      "appsettings.development.json",
      "appsettings.staging.json",
      "appsettings.production.json",
      "web.config"
    ]
  },
</code></pre>

<p>I have 3 corresponding startup classes that uses appropriate <code>appsettings</code> based on environment</p>

<pre><code>var builder = new ConfigurationBuilder()
    .SetBasePath(env.ContentRootPath)
    .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: false, reloadOnChange: true);
</code></pre>

<p>However when I publish the application then all 3 appsettings files end up in all environments. How do I publish environment specific appsetting file?</p>