command/build: split the logic of normal building and install building; #478
command/build: clean the cortex.json after cortex.scripts; fixes #478