Using the command 'dotnet watch run' to monitor changes in server code and 'ng build --watch' for Angular code updates has been successful. It rebuilds the code correctly into directories "bin/" and "wwwroot/" respectively.
myapp.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>myapp</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<!-- extends watching group to include *.js files -->
<Watch Include="wwwroot\*.js;bin\**\*"/> <!-- Exclude="node_modules\**\*;**\*.js.map;obj\**\*;bin\**\*" /> -->
</ItemGroup>
</Project>
The configuration in my Startup.cs allows it to read from the "wwwroot" file and serve the transpiled TypeScript.
Startup.cs
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;
...
app.UseMvc();
}
}
}
To facilitate running both watch commands in one terminal, I set up the project to use "npm run saw". This allows the client and server to operate on the same port while serving the application using "dotnet run."
package.json
"scripts": {
"ng": "ng",
...
"saw": "npm run start:all:watch"
}
In order to re-serve the "wwwroot" folder after a rebuild in dotnet core, especially when using localhost:5000, additional steps may need to be implemented within the project structure.