Two options work well if you're trying for perfect lines and angles.
The first is to turn on angle snap, lay down your fence, and then set paths to "Snap to barriers" (with angle snap OFF). Problems with that mostly only occur on corners and turns, where the path sizing is such that it doesn't snap perfectly to the barrier around those bends. This is the option I use for straight sections.
The second is, as
@Dr4gon indicated, lay down your paths first, then lay down your barriers and use the ability to drag fence posts to precisely where you want them to line the barrier up nicely. This is my favorite approach as well, so I totally agree with him. I usually turn angle snap on when laying down the paths, and then turn it off when laying the fence in.
I also don't try to get the fence perfect when I put it down; I put the whole enclosure down first, then select individual fence posts one at a time and drag them to get things aligned nicely, using the + button to add additional fence posts as needed.
A tip for you if you haven't figured it out yet, when you want "curved" barrier sections for barrier types that don't have that option, first lay the barrier down with a type that does (such as hedges) and once it is in place, select all the barrier sections and change it to what you want. I do this all the time, as I'm fond of the wooden post barrier and it doesn't have the option to curve. So I lay down the whole habitat with a hedge barrier to get my curves in place, then change it to wooden posts.
Would be nice if we had a "Snap to path" option for barriers the way we have "Snap to barrier" for paths....seeing as the latter doesn't work well but the former would probably be fantastic.
There's a third option too, which is what I usually do. Don't try to make everything perfect lines and angles in the first place. Nature is not generally quite that orderly, so make your layouts more natural looking. If you use natural barriers and the null (invisible) fence more often than not, the whole "lined up perfectly" is a moot point.