Basically how you build a solo is very simple(once you understand how to do it that is).
You take a scale that is in that key and, using your imagination, build a lead.
You don't just randomly finger notes, you have to actually know what it is you are doing.
But that comes with practice and experience.
It sounds like you are a beginner, so I'll let you know about a book that is made for people that want to know theory, but don't have a teacher.
It is called "Teach yourself guitar theory"
It costs about $8 and is useful if you pay attention.
You can get it here
http:/www.musiciansfriend.com
When attempting the impossible, you achieve the best possible