add support for dotnet watch run
Liero opened this issue · comments
I would love to see my scss files recompiled when dotnet watch --project myproject.csproj run
, just like my typescript files.
Typescript is intergrated into msbuild using following reference:
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="4.5.2">
Now when I change any typescript file, it is recompiled and the output javascript is hot reloaded in my browser event without reloading a page.
BTW, I also like how typescript automatically discovers tsconfig files in my solution.
As far as I know, this is already possible and no change to this tool needs to be made. See the section on dotnet watch in the project's README.md:
https://github.com/excubo-ag/WebCompiler#compile-on-save-dotnet-watch
Please try that as a starting point and let me know if that section needs changes (I am personally not using dotnet watch at all).
Thanks
Stefan
@stefanloerwald:
I need to run dotnet watch tool run webcompiler
as a separate process in order to watch changes. And this command must be executed from exact directory to make relative paths work with --files
, which is not very convenient.
following changes to csproj only compiles once:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<Target Name="ToolRestore" BeforeTargets="PreBuildEvent">
<Exec Command="dotnet tool restore" StandardOutputImportance="high" />
</Target>
<Target Name="PreBuild" AfterTargets="ToolRestore">
<Exec Command="dotnet webcompiler -c webcompilerconfiguration.json -f webcompilerfiles.conf" StandardOutputImportance="high" />
</Target>
<ItemGroup>
<Watch Include="**\*.scss" />
</ItemGroup>
When I change scss, the browser is reloaded (it shouldn't), but the compiler is not invoked. At least in .NET 6
I think in .NET 5 it triggered complete rebuild - not just scss.
Notice that Microsoft.TypeScript.MSBuild
rebuilds only .ts files and it does incremental build