title: Can I hot module reload the server (.NET Core) and client (Angular) at the same time?
body: <p>I'm using <strong>'dotnet watch run'</strong> to watch for changes in my server code and <strong>'ng build --watch'</strong> to watch for changes in my Angular code. Both are rebuilding the code properly into <strong>"bin/"</strong> and <strong>"wwwroot/"</strong> respectively.</p>
  
  <h2>myapp.csproj</h2>
  
  <pre><code>&lt;Project Sdk="Microsoft.NET.Sdk.Web"&gt;
  
    &lt;PropertyGroup&gt;
      &lt;TargetFramework&gt;myapp&lt;/TargetFramework&gt;
    &lt;/PropertyGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;Folder Include="wwwroot\" /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="2.0.0" /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;!-- extends watching group to include *.js files --&gt;
      &lt;Watch Include="wwwroot\*.js;bin\**\*"/&gt; &lt;!-- Exclude="node_modules\**\*;**\*.js.map;obj\**\*;bin\**\*" /&gt; --&gt;
    &lt;/ItemGroup&gt;
  
  &lt;/Project&gt;
  </code></pre>
  
  <p>My <strong>Startup.cs</strong> is set to read from the "wwwroot" file and serve my transpiled TypeScript.</p>
  
  <h2>Startup.cs</h2>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Threading.Tasks;
  using Microsoft.AspNetCore.Builder;
  using Microsoft.AspNetCore.Hosting;
  using Microsoft.Extensions.Configuration;
  using Microsoft.Extensions.DependencyInjection;
  using Microsoft.Extensions.Logging;
  using Microsoft.Extensions.Options;
  // using Microsoft.AspNetCore.SpaServices.Webpack;
  
  namespace myapp
  {
      public class Startup
      {
          public Startup(IConfiguration configuration)
          {
              Configuration = configuration;
          }
  
          public IConfiguration Configuration { get; }
  
          // This method gets called by the runtime. Use this method to add services to the container.
          public void ConfigureServices(IServiceCollection services)
          {
              services.AddMvc();
          }
  
          // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
          public void Configure(IApplicationBuilder app, IHostingEnvironment env)
          {
              if (env.IsDevelopment())
              {
                  app.UseDeveloperExceptionPage();
                  /*app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions {
                      HotModuleReplacement = true
                  });*/
              }
              app.UseDefaultFiles(); // URL rewriter to serve default web page
              app.UseStaticFiles(); // makes files in wwwroot servable
              app.UseMvc();
          }
      }
  }
  </code></pre>
  
  <p>I run the project with <strong>"npm run saw"</strong> concurrently so both watch commands can be in the same terminal. I want the client and server to run on the same port so that's why I let "dotnet run" serve the app.</p>
  
  <h2>package.json</h2>
  
  <pre><code>"scripts": {
      "ng": "ng",
      "start:client": "ng serve",
      "build:client": "ng build",
      "build:client:watch": "ng build --watch",
      "build:server": "dotnet build",
      "build:all": "npm run build:client &amp;&amp; npm run build:server",
      "build:client:prod": "ng build --prod --env=prod",
      "build:all:prod": "npm run build:client:prod &amp;&amp; npm run build:server",
      "test:client": "ng test",
      "lint:client": "ng lint",
      "e2e:client": "ng e2e",
      "restore": "dotnet restore",
      "start:all": "ng serve --live-reload false &amp;&amp; dotnet run",
      "start:all:watch": "concurrently -k \"npm run build:client:watch\" \"dotnet watch run\"",
      "saw": "npm run start:all:watch"
    }
  </code></pre>
  
  <p>Finally, here is my overall project structure. How can I <strong>re-serve the "wwwroot" folder</strong> if I'm using dotnet run on <strong>"localhost:5000"</strong> after dotnet core detects that "wwwroot" (or server in "bin") has been re-built?</p>
  
  <p><a href="https://i.stack.imgur.com/EUFfT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EUFfT.png" alt="enter image description here"></a></p>