When to publish a book? I am presently doing MSc (Information Technology) in India. I really like teaching and have a passion for it. Based on my Masters degree I will get a designation of Assistant professor (hope so I get it!), but to be a Professor we need a PhD degree, so I was thinking of doing a Phd (Computer Science) not right after the Masters but after some years of teaching experience. At present I don't have much knowledge about PhD (nearly zero). 

I know we need to publish the thesis in PhD,but my question is do we have to publish books (about courses like Java, Operating System etc, since I am talking about IT/CS i gave these subjects) in PhD? This is because right now in my Masters I was thinking of publishing a book for a local course of Bachelors (BSc IT) in my region. 

So if we need to publish certain number books in PhD, then I should wait for writing and publishing that local book till I join a PhD or should I start writing and publish it right in my Masters and this published book will be considered in my PhD?
No.  Absolutely not.

Do not even start writing a book until you have tenure, unless publishing a book is a requirement for tenure (which would be very strange for computer science).  Writing books well is extremely hard; it requires significant time away from your research (which you need to finish your PhD, get a job, and get tenure), teaching, paper-writing, professional networking, job-hunting, proposal writing, and advising.  And writing books badly can only hurt you.