WiFi.h not found, with ldf_mode = off and WiFi in lib_deps

I’ve seen other issues with the same problem , but I cannot find a satisfactory solution for this …

As our project grows and grows, I want to disable the LDF and specify each used library explicitly in the platformio.ini. Searching for dependencies is taking way too long, and is not changing that often.

It all works fine when specifying build-in libraries like SPIFFS, Preferences, FS etc in the lib_deps … but the only one not working is WiFi

So can anybody tell me why the platformio.ini as copied below, still fails to compile with a fatal error: WiFi.h: No such file or directory when being included in on of the .cpp files with #include "WiFi.h"

If I specify the include with a full absolute path like #include "c:\Users\Bas\.platformio\packages\framework-arduinoespressif32\libraries\WiFi\src\WiFi.h" it is working btw, without errors

[env]
platform = espressif32@^5.0.0
board = esp32dev
framework = arduino

lib_ldf_mode = off
lib_deps = 
    bblanchon/ArduinoJson@^6.19.0
    EEPROM
    ESP32 BLE Arduino
    FS
    https://github.com/dmkishi/Dusk2Dawn.git
    https://github.com/I-Connect/Esp32Logging
    https://github.com/I-Connect/Sense_Timer
    https://github.com/I-Connect/SenseSupport
    https://github.com/I-Connect/StreamDebugger
    https://github.com/sudar/MemoryFree
    Preferences
    PubSubClient
    SPIFFS
    WiFi
    Wire

The dependency is found during build btw:

Scanning dependencies...
Dependency Graph
|-- ArduinoJson @ 6.19.4
|-- EEPROM @ 2.0.0
|-- ESP32 BLE Arduino @ 2.0.0
|-- FS @ 2.0.0
|-- Dusk2Dawn @ 1.0.1+sha.2e12244
|-- ESP32 logger @ 1.0.2+sha.2e1d2b2
|-- Sense_Timer @ 0.0.0+sha.fe2adaa
|-- SenseSupport @ 0.0.0+20210527222300.sha.0f233c2
|-- StreamDebugger @ 1.0.3+sha.503d574
|-- MemoryFree @ 0.0.0+20220727233332.sha.b1db159
|-- Preferences @ 2.0.0
|-- PubSubClient @ 2.8.0
|-- SPIFFS @ 2.0.0
|-- WiFi @ 2.0.0
|-- Wire @ 2.0.0