Depends, this is what we did.
Our neighbor's dog used to bark in the middle of the night. We saw the neighbor's lights still on, we talked to them. We told them the dog bark really close to our bedroom window, we cannot sleep at all. They put the dog inside for a few nights.
Then there's a few times, the dog bark like 3, 4am in the morning. My hu*****and turned on the water hose, and spray at the dog in the face over the fence. The dog stopped barking after that.
Then there was a few very cold winter days (20F temperature), the dog dig a hole through the fence and came to warm up in our yard. We took care of the dog (feed him and put him in our garage), and talked to the owner after he get back. After that, the dog treat us super nice.
Over all, I think spray over the fence on the nose if a good trick (do it when the neighbor is not home :-)
