This study evaluates the techno‐economic feasibility of a new biomass‐driven cogeneration system designed to fulfill all energy requirements (i.e., electricity, hot water, cooling, and heating) of a grid‐connected building throughout the year. The proposed system is also expected to achieve the goal of zero energy building (ZEB). A 10‐story residential complex is considered as the present case study. The study is carried out for three cities of Iran with different climate conditions (mild, hot, and cold) and with the annual energy requirements of about 104,472 kWh, 128,784 kWh, and 142,518 kWh, respectively. After defining two objective functions (“annual actual benefit” and “loss of building requirements supply probability”), the system is optimized by using the Non‐dominated Sorting Genetic Algorithm (NSGA‐II). The results show that the designed system is economically viable with the levelized cost of energy (LCOE) of about 0.15–0.2 $/kWh. The results also indicate that if the cost of CO2 emission is taken into consideration, the annual benefit of the system is decreased by 16%–25%. Finally, a sensitivity analysis shows that heat generation cost and electricity selling price have the most and the least effect on the system's annual benefit, respectively.