It depends on what you mean by rebuilding it and on what parts you have or can get for free or cheap. I wouldn't spend much on it, but if it is a matter of tearing it down, reusing parts or using ones from your or someone else's junk bin, reassembling after cleaning, re-greasing everything, and replacing stuff like cables and brake pads that is a different matter.
If buying much in the way of new parts the cost will go up pretty fast and will quickly exceed the value of the bike.