Detect when a build is started

Is there a way to detect when a build is started?
I have some code that subscribes to
EditorSceneManager.newSceneCreated
With a

[InitializeOnLoad]

It seems like the Building Process creates a few empty scenes, which then executes my delegate.
I tried using

#if UNITY_EDITOR

But off course that doesn’t work because building still happens inside the editor.
Also looked into

UnityEditor.Compilation

but couldn’t find a solution.

would any of these be accessible,
https://github.com/Unity-Technologies/UnityCsReference/search?q=build+started&unscoped_q=build+started

The AssemblyBuilder looked promesing but as i understode the use of it is to add scripts to the assembly that are outside the asset folder. So you have to create an AssemblyBuilder, give it a path and an array of scripts.
Will look further into EditorCompilation class, but my main question for that one is how to get a reference to it?

Just found this one. Sounds like it would do the trick. Not behind my pc atm, will test later and post an answer if it works or not.

doesnt seem to do anything if hit build, does trigger on script recompile when edit something, like this one
https://github.com/m3rt32/UnityElevatorCompiler

Thanks for checking.

ok found it:

UnityEditor.BuildPipeline.isBuildingPlayer