Add build task and fix build errors