Difference between publishing textbooks and publishing research for acquiring tenure
I have spoken with a few people who have written textbooks. The universal advice they have given is never write a textbook until after you have received tenure. 

In general, you get very little or no credit for writing a textbook, as it doesn't really help in any of the major "checkboxes" for tenure—research, teaching, and service. In addition, the time that you spend working on the textbook can generally be put to better use in writing grant proposals or working on peer-reviewed manuscripts.

I know from personal experience, when I was a graduate student, that there was an assistant professor in my department who spent all of his time working on a textbook. He let his research languish, and ended up with a textbook but no promotion to associate professor.