Similiar issues with pico W but may not be pico W specific.
Doing some basic testing of getting Dallas OneWire code work for temp sensor. Blink works no problem. Download basic code for Dallas OneWire that works on old school Arduino and get the uploading message stuck on the IDE. I think it is most likely a race condition in that the IDE is doing the upload via the mounted drive and suspect that the Serial.begin(9600) in the setup code triggers a com port registration. If something in the code is problematic then the establishing of the com port has an issue.
I commented out code related to reading the OneWire pin and the normal/expected behavior of downloading code, having it run and loading message go away returns. More importantly can change code and redownload. When the IDE gets hung up in the Loading message that doesn't go away need to exit IDE and restart with boot sel button on pico W.
For the pico W seem to recall the blink code is problematic in that pico W used that pin for the wifi module but gave it back via some other process. If you try using the RP2040 arudino board definition doesn't work. Use the RP2040 pico W board definition from earlephilhower then works.
The point is given the dynamic nature of RP2040 setting up pins to have a specific function may be creating some hardware issues that causes the board to not respond as expected.
It would be nice if the IDE didn't require a restart to recover from code on the board not working as expected.