I have done work in Gloucester and they are real sticklers for lot lines and setback heights. You might want to check out the grandfather clauses very carefully so that you don't violate your status. I have done two new foundations in Gloucester, one for acarriage house and one for a barn, both on Eastern point. One was at Demarco's place with the big lamps entry rock wall, there I shored up the whole structure internally, making sure all of the connections were nailed and not just mortised and tenoned - especially the joist to sill connection, then I put huge angle braces from top plate to the center of the floor. I then jacked up the entire building from about 4 feet inside the sill. This would be easier if you did it with large I beams running across the joists all the way through the building. I then had a small back hoe come in and demo the rubble foundation and dig down 4'9". I poured a footing by filling up the bottom of our hole and then laid a concrete block foundation and some piers for the center girder beam. Voila, done. This is pretty labor intensive. I was just working for a regular contractor when I did this, although you can try to find someone who jacks for a living, but then you would have to coordintate the restructuring, the jacking and the new foundation where a General contractor could probably do it all much easier. The inspector made us reinforce the blocks with rebar and fill every two courses. Do not attempt the jacking yourself if you don't know what you are doing. It might be cheaper to jack it and move it to a new foundation that you have already poured, although if you keep the grandfathered location you can make better use of your property. Another one I did out there was the carriage house across from the yacht club, the last building on the left before the audobon marsh and the lighthouse at eastern point. This was built on brick piers instead of an outer rubble foundation. If your barn is on piers then this is easier. Many of the piers had fallen over b/c of frost heaving inferior footings and the building being hit by storm waves at one point. We basically jacked each pier one at a time, demolished it, dug a new footing, poured it, and bricked up a new pier. Grubby but effective.
Your main consideration should be whether or not it might be better to just nuke it. If not, then at least put a huge tarp over the roof to protect what wood you have that isn't rotted yet. Water is death to wood. Find out where you can get a mongo tarp and protect it. Then do the foundation et. al. And the answer is, "NO" I'm don't do this any more, I'm on my second career.