Your question is open to interpretation. By this I mean that when observed in operation the Microchip device programming tools appear to allow the users code to run during the programming operation. For the PIC18 family of parts this is not the case.
The Microchip device programming application causes the PIC18 to go through reset several time before the flash update begins. User code will run after each of the resets, but for how long depends on Microchip device programming application.
The most effective solution I've found comes in two parts:
- Design the hardware to power up in a safe state when the PIC18 device is blank or not present.
- Wait from 0.5 seconds to 3.5 seconds after Power-On-Reset before setting any GPIO pins as outputs.
The second part may not be possible in all applications but it does make using the MPLAB debugger more reliable.