O’Reilly has a free online book called So You Want to Write a Book. It is a guide for new authors which talks about from writing a proposal, getting a contract with your publisher, start writing, edit your work and market your book. It is a good book especially if you want O’Reilly to be your publisher:
… In one sense, the market for the book is implicit in its purpose and audience. If there’s a real need for the book, and you do a good job of addressing that need, the book will sell. However, there are often ancillary factors, such as competing works, industry trends, or size of user base, that may have bearing on just how successful the book will be.
Needless to say, we have our own understanding of the market potential in various areas. If you think you have a good idea, but don’t feel you have the resources to demonstrate its marketability, feel free to contact us and discuss the matter. Perhaps we can help you through this stage.
Of course, if you do have statistics for the size of the market for the book, they’d be more than welcome. Similarly, if you know that several companies are planning to adopt or promote a given technology, this might be an important point to make about your audience…
So You Want to Write a Book? – [O’Reilly]