dotnet-websharper / dotnet-ws

The `dotnet ws` tool
Apache License 2.0
1 stars 3 forks source link

Cancel a compilation process if a new one needs to be started #24

Open granicz opened 1 year ago

granicz commented 1 year ago

In watch mode (#22), changing a source file could result in recompilation with the earlier attempt still running. This can arise in two separate situations:

1) When there is no booster instance for the given project (yet, or deliberately by turning the booster off), and an ordinary dotnet build was triggered from dotnet ws. 2) When the project is already boosted.

To handle a parallel recompilation request, in the first case, dotnet ws needs to "tag" each dotnet build process that it spawns in a way that can be queried quickly by a new dotnet ws instance to find out if a given project is being compiled or not. If so, the new dotnet ws instance can kill that process first before dispatching a new compilation session(*).

In the second case, the Booster needs to be able to terminate a compilation session if it receives a new message to compile the same project and there is already a compilation session in progress.

(*) It would be lovely to use process groups, but short of messing with OS-specific implementations, we can just use a [ws-{hash}] prefix for the title of the process, where {hash} is the hash of the full-path of the project file behind the project compiled.

Jooseppi12 commented 1 year ago

As of 0.1.16 1) is done, but 2) still needs to be implemented