Seismic hazards represent a permanent threat to buildings. The paper argues that risk-oriented approaches provide an interesting solution to account for the long-term resilience of buildings, both for the design of new structures and the rehabilitation of existing ones. The proposed research draws upon the standard definition of risk as a function of vulnerability, hazard and exposure to develop an optimization-based methodology for risk appraisal of buildings in seismic conditions. The proposed methodology allows to identify the optimum layout and thickness of shear walls in a reinforced concrete frame, based on a target risk performance. This is achieved through the coupling of an evolutionary computing environment with an object-oriented structural analysis tool, involving its native Application Programming Interface (API). The latter allows to automate the search for the optimum shear wall configuration solution. The research is validated on the Beichuan Hotel building in Old Beichuan (China), heavily affected by the 2008 Wenchuan Earthquake. The paper evidences that the adoption of the proposed methodology leads to a risk reduction of about 80% compared to the as-built scenario, with additional benefits from both a financial and building functionality perspective.