Code in doFirst statement inside a task (type: War) that is part of finalizeBy statement doesn not working

This error is reproducible from gradle 7.4 onwards. In gradle 7.3.3 the expected behaviour is correctly.
Code in doFirst statement inside a task (type: War) that is part of finalizeBy statement doesn not working
I have the following gradle task structure (This gradle task structure is simplification of the real structure but is very usefull to reproduce the error)

task taskF (type: War){
    outputs.upToDateWhen { false }
    doFirst{
	    println "Runninf before taskF"
   }

   doLast{
        println "Runninf after taskF"
  }
}

task taskE(type: War) {
    outputs.upToDateWhen { false }
    doFirst{
	    println "Running before taskE"
   }

   doLast{
        println "println after taskE"
  }
}

task taskD(type: Jar) {
    outputs.upToDateWhen { false }
    doFirst{
        println "Running before taskD"
    }

    doLast{
        println "Running after taskD"
    }
}

task taskC {
  doFirst {
    println "Running taskC"
  }
  finalizedBy taskD, taskE, taskF
}

task taskB{
  doFirst {
    println "Running taskB"
  }
  finalizedBy taskC
}

task taskA {
	doLast{
		println "Running taskA"
	}

	finalizedBy taskB
}
taskE.mustRunAfter taskD

Expected Behavior

When I run ./gradlew taskA I can see the following output:

Task :taskA
Running taskA

Task :taskB
Running taskB

Task :taskC
Running taskC

Task :taskD
Running before taskD
Running after taskD

Task :taskE
Running before taskE
Running after taskE

Task :taskF
Running before taskF
Running after taskF

All the tasks execute correctly

Current Behavior

When I run ./gradlew taskA I can see the following output:

Task :taskA
Running taskA

Task :taskB
Running taskB

Task :taskC
Running taskC

Task :taskD
Running before taskD
Running after taskD

But tasks E and F, that also form part of finalizeBy statement in the task C, does not execute

Context

This error is not letting me generate the war to deploy in a client

Steps to Reproduce

You can use the example provided for me an execute ./gradlew taskA

Note: if you change the task E and F and remove (type: War), then the code inside doFirst{} statement execute correctly

Environment

Gradle 7.4.2,Gradle Enterprise plugin 3.8.1

Composite build (6 included builds)

Operating system Linux 5.13.0-39-generic (amd64)
CPU cores

Number of cores available to the build JVM|4 cores||
|Max Gradle workers|4 workers||
|Java runtime|Private Build OpenJDK Runtime Environment 1.8.0_312-8u312-b07-0ubuntu1~20.04-b07||
|Java VM|Private Build OpenJDK 64-Bit Server VM 25.312-b07 (mixed mode)||
|Max JVM memory heap size|2.6 GiB||
|Locale|Spanish (Argentina)||
|Default charset|UTF-8||
|Username|andresbenavides||
|Public hostname|tecso-ThinkPad-T470||
|Local hostname|(N/A)||
|Local IP addresses|172.17.0.1, 192.168.0.212|

Running ./gradlew taskA with your example as provided does execute all 6 tasks for me (taskA, taskB, taskC, taskD, taskE, and taskF) on Gradle 7.4.2, so there does appear to be some other variable required to reproduce that isn’t necessarily identified yet.