dotnet watch (hot reload) can execute a process (target) before
Description
The new hot reload works amazingly and it would be great if we can get some extension points, we can hook on, to teach it how to handle other kind of files.
Describe the solution you'd like
- One solution could be add the capability to include a target to be executed before the reload happens
<ItemGroup>
<styles Include="styles.css" />
<Watch Include="@(styles)" WatchAction="BrowserRefresh" ExecuteTargetBefore="SomeTargetThatHandlesReload"/>
</ItemGroup>
- Provides a way to include our own
FileHandlertoHotReload.cs:
public HotReload(ProcessRunner processRunner, IReporter reporter)
{
_staticFileHandler = new StaticFileHandler(reporter);
_scopedCssFileHandler = new ScopedCssFileHandler(processRunner, reporter);
_compilationHandler = new CompilationHandler(reporter);
}
Additional context
The motivation for this is to give the chance to provide a unified experience when working on projects that integrate other tools like nodejs postcss.
For example this:
<ItemGroup>
<styles Include="styles.css" />
</ItemGroup>
is taken by a custom target that replaces tailwind directives on it and emits the result on /bin/debug/net6.0/wwwroot, I know this can be done by emitting the file directly on the project's wwwroot but having compiled files on it does not look elegant at all plus creates common confusions to new developers like "should I include this on source control?".
🌟 Thanks for taking the time to read through.
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
@javiercn @pranavkm I have added two more issue on the dotnet/sdk repo that are related with this, would be great if you could take a look:
- [ ] https://github.com/dotnet/sdk/issues/19988
- This is very similar to this ticket so probably need to close as duplicate
- [ ] https://github.com/dotnet/sdk/issues/19987
- The first build does not notify msbuild it was done with dotnet-watch