Create target directories explicitly before copying files into them. According to the documentation of copy_directory this should not be necessary but our CI jobs say differently.
copy_directory
Fixes problems seen in !487 (merged), !470 (merged), etc.