title: ASP.NET Core 2.0: static file (site.min.js) not found
body: <p>I want to deploy an ASP.NET Core web application via publishing profiles in Visual Studio 2017. Everything is copied to the destination folder and works fine, except the "site.js" file. In the destination folder, I see in the wwwroot/js folder both site.js and site.min.js, but the latter is empty. I also get a console error in the browser:</p>
  
  <p><code>Failed to load resource: the server responded with a status of 404 (Not Found) 
   site.min.js</code></p>
  
  <p>In page source however I see the file loaded correctly:</p>
  
  <p><code>&lt;script src="/wwwroot/js/site.min.js"&gt;&lt;/script&gt;</code></p>
  
  <p>Program.cs file:</p>
  
  <pre><code>public class Program
  {
      public static void Main(string[] args)
      {
          var host = new WebHostBuilder()
               .UseKestrel()
               .UseContentRoot(Directory.GetCurrentDirectory())
               .UseIISIntegration()
               .UseStartup&lt;Startup&gt;()
               .Build();
  
          host.Run();
      }
  }
  </code></pre>
  
  <p>Service configuration in Startup.cs:</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
      services.AddMvc();
  }
  public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  {
      app.UseStaticFiles();
  
      if (env.IsDevelopment())
      {
          app.UseDeveloperExceptionPage();
          app.UseBrowserLink();
      }
      else
      {
          app.UseExceptionHandler("/Home/Error");
      }
  
      app.UseMvc(routes =&gt;
      {
          routes.MapRoute(
              name: "default",
              template: "{controller=Home}/{action=Index}/{id?}");
      });    
  }
  </code></pre>
  
  <p>_Layout.cshtml:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0" /&gt;
      &lt;title&gt;Dashboard&lt;/title&gt;
  
      &lt;environment include="Development"&gt;
          &lt;link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" /&gt;
          &lt;link rel="stylesheet" href="~/css/site.css" /&gt;
      &lt;/environment&gt;
      &lt;environment exclude="Development"&gt;
          &lt;link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css"
                asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
                asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" /&gt;
          &lt;link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" /&gt;
      &lt;/environment&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;nav class="navbar navbar-inverse navbar-fixed-top"&gt;
          &lt;div class="container"&gt;
              &lt;div class="navbar-header"&gt;
                  &lt;button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"&gt;
                      &lt;span class="sr-only"&gt;Toggle navigation&lt;/span&gt;
                      &lt;span class="icon-bar"&gt;&lt;/span&gt;
                      &lt;span class="icon-bar"&gt;&lt;/span&gt;
                      &lt;span class="icon-bar"&gt;&lt;/span&gt;
                  &lt;/button&gt;
                  &lt;a asp-area="" asp-controller="Home" asp-action="Index" class="navbar-brand"&gt;Home&lt;/a&gt;
              &lt;/div&gt;
              &lt;div class="navbar-collapse collapse"&gt;
                  &lt;ul class="nav navbar-nav"&gt;
                      &lt;li&gt;&lt;a asp-area="" asp-controller="Home" asp-action="Create"&gt;View orders&lt;/a&gt;&lt;/li&gt;
                  &lt;/ul&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/nav&gt;
      &lt;div class="container body-content"&gt;
          @RenderBody()
          &lt;hr /&gt;
          &lt;footer&gt;
              &lt;p&gt;&amp;copy; 2018 - test app&lt;/p&gt;
          &lt;/footer&gt;
      &lt;/div&gt;
  
      &lt;environment include="Development"&gt;
          &lt;script src="~/lib/jquery/dist/jquery.js"&gt;&lt;/script&gt;
          @*&lt;script src="~/lib/jquery/jquery-validation/dist/jquery.validate.js"&gt;&lt;/script&gt;*@
          &lt;script src="~/lib/bootstrap/dist/js/bootstrap.js"&gt;&lt;/script&gt;
          &lt;script src="~/js/site.js"&gt;&lt;/script&gt;
      &lt;/environment&gt;
      &lt;environment exclude="Development"&gt;
          &lt;script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.0.min.js"
                  asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
                  asp-fallback-test="window.jQuery"
                  crossorigin="anonymous"
                  integrity="sha384-K+ctZQ+LL8q6tP7I94W+qzQsfRV2a+AfHIi9k8z8l9ggpc8X+Ytst4yBo/hH+8Fk"&gt;
          &lt;/script&gt;
          &lt;script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/bootstrap.min.js"
                  asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
                  asp-fallback-test="window.jQuery &amp;&amp; window.jQuery.fn &amp;&amp; window.jQuery.fn.modal"
                  crossorigin="anonymous"
                  integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"&gt;
          &lt;/script&gt;
          &lt;script src="~/wwwroot/js/site.min.js" asp-append-version="false"&gt;&lt;/script&gt;
      &lt;/environment&gt;
  
      @RenderSection("Scripts", required: false)
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The site.js is in the wwwroot/js folder (I didn't move it or recreate it).
  I didn't change the bundleconfig.json either. Its content is the following:</p>
  
  <pre><code>[
    {
      "outputFileName": "wwwroot/css/site.min.css",
      // An array of relative input file paths. Globbing patterns supported
      "inputFiles": [
        "wwwroot/css/site.css"
      ]
    },
    {
      "outputFileName": "wwwroot/js/site.min.js",
      "inputFiles": [
        "wwwroot/js/site.js"
      ],
      // Optionally specify minification options
      "minify": {
        "enabled": true,
        "renameLocals": true
      },
      // Optionally generate .map file
      "sourceMap": false
    }
  ]
  </code></pre>
  
  <p>Is it something that I am missing out?
  Thank you in advance.</p>
  
  <p>UPDATE:</p>
  
  <p>I changed the site.min.js script tag:</p>
  
  <pre><code>&lt;script src="~/js/site.min.js" asp-append-version="true"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>I no longer get the 404 error, but the site.min.js is still empty and therefore is a minification issue.</p>
  
  <p>UPDATE 2:</p>
  
  <p>site.js content:</p>
  
  <pre><code>$('#chkMinId').change(function () {
      var checked = $(this).is(':checked');
      var target = $('#txtMinId');
      console.log(checked ? 'yes' : 'no');
  
      if (!checked) {
          target.prop('disabled', true);
      } else {
          target.removeAttr('disabled');
      }
  });
  
  $('#chkMaxId').change(function () {
      var checked = $(this).is(':checked');
      var target = $('#txtMaxId');
      console.log(checked ? 'yes' : 'no');
  
      if (!checked) {
          target.prop('disabled', true);
      } else {
          target.removeAttr('disabled');
      }
  });
  </code></pre>