As soon as you start writing your book, you should start marketing it. Create a Twitter, Instagram or Facebook account (whatever works best for promoting your book) and share the writing process with the world. This way, you'll start building an audience before the book is finished.
I created a web site for my book Entreprenerd before I started writing the book, and I created a web page for every chapter. On these pages, I shared some of the research I did while writing the chapter.
Comparing Royalties A Word About Self-Promotion