The U.S. Department of Energy has launched the commercial building initiative (CBI) in pursuit of its research goal of achieving zero-net-energy commercial buildings (ZNEB), i.e., ones that produce as much energy as they use. Its objective is to make these buildings marketable by 2025 such that they minimize their energy use through cutting-edge, energy-efficiency technologies and meet their remaining energy needs through on-site renewable energy generation. This paper examines how such buildings may be implemented within the context of a cost- or CO2-minimizing microgrid that is able to adopt and operate various technologies: photovoltaic (PV) modules and other on-site generation, heat exchangers, solar thermal collectors, absorption chillers, and passive/demand-response technologies. A mixed-integer linear program (MILP) that has a multi-criteria objective function is used. The objective is minimization of a weighted average of the building's annual energy costs and CO2 emissions. The MILP's constraints ensure energy balance and capacity limits. In addition, constraining the building's energy consumed to equal its energy exports enables us to explore how energy sales and demand-response measures may enable compliance with the ZNEB objective. Using a commercial test site in northern California with existing tariff rates and technology data, we find that a ZNEB requires ample PV capacity installed to ensure electricity sales during the day. This is complemented by investment in energy-efficient combined heat and power (CHP) equipment, while occasional demand response saves energy consumption. A large amount of storage is also adopted, which may be impractical. Nevertheless, it shows the nature of the solutions and costs necessary to achieve a ZNEB. Additionally, the ZNEB approach does not necessary lead to zero-carbon (ZC) buildings as is frequently argued. We also show a multi-objective frontier for the CA example, which allows us to estimate the needed technologies and costs for achieving a ZC building or microgrid. Copyright © 2010 John Wiley & Sons, Ltd.