I'll just throw in my 2 cents having just gone through this. The basics is bought a barn bike for $300, engine turned, rewired and cleaned everything, finally got it to run, was working on synch and timing when clank, clank , BOOM. Number 4 connecting rod bolts dropped out (in an engine that had NEVER been split open, so no one has any idea what really caused this on a bike with a 'bullet proof' lower, but that's just the special kind of luck I have), seized the crank (to the point where even after the engine was out it couldn't be removed without a very large mallet), shattered the sleeve and bent the con rod. Opted to rebuild than buy a runner, so $50 engine (K6, local shop had shelves of them in as is condition), $1000 in parts (cx1 cam, 836 kit because the hone was no good, cyclex cam tensioner system, super gasket kit, offset sprockets, etc), and $1600 in shop labor (thats WITH my mechanic charging $55/hr and discounting me, he had over 40 working hours into the thing). For those of you keeping score at home. Thats $2950 so far, not including everything else I purchased and did (full re-wiring, dyna s system, 5ohm coils, every piece of wiring and electrical component is new except for the negative ground and the positive to the starter).
TLDR: Buy a bike that already runs.
If you have the time, space, tools and ability to rebuild it, then MAYBE. But we ran into problems at every step; ie can't reuse pistons, new bore is no good, can't use this chain it's too short, etc etc etc.
I know I will NEVER get back out what I put into this bike so far so my solution is to keep it until one of us dies.