Traditionally this error has been a result of the corrupted local device datastore that stores information about all your devices and emulators. However during a recent incident where I was trying to help someone in the office with this issue, I uncovered another strange reason for this issue to show up.
In the case of the person whose machine I was trying to troubleshoot had an interesting symptom. Only 1 project on this machine when I pressed F5 gave this error. All the others worked. Which kind of implied that the datastore is healthy.
On further investigation it turns out that there is a .ico file in the project that does not exist on the disk. I removed it and hey the deployed when like a charm.
So in the nutshell if you are seeing this error message
The operation could not be completed. The device is not connected
on just a few of your projects, do check that all the files in your solution/project that are marked as content are actually present on the disk. This can happen sometimes when you copied a project from someone else and didn't get all the files or you may have accidentally just removed a few files from the disk.