Current district energy optimisation depends on perfect foresight. However, we rarely know how the future will transpire when undertaking infrastructure planning. A key uncertainty that has yet to be studied in this context is building-level energy demand. Energy demand varies stochastically on a daily basis, owing to activities and weather. Yet, most current district optimisation models consider only the average demand. Studies that incorporate demand uncertainty ignore the temporal autocorrelation of energy demand, or require a detailed engineering model for which there is no validation against real consumption data. In this paper, we propose a new 3-step methodology for handling demand uncertainty in mixed integer linear programming models of district energy systems. The three steps are: scenario generation, scenario reduction, and scenario optimisation. Our proposed framework is data-centric, based on sampling of historic demand data using multidimensional search spaces. 500 scenarios are generated from the historical demand of multiple buildings, requiring historical data to be nonparametrically sampled whilst maintaining interdependence of hourly demand in a day. Using scenario reduction, we are able to select a subset of scenarios that best represent the probability distribution of our large number of initial scenarios. The scenario optimisation step constitutes minimising the cost of technology investment and operation, where all realisations of demand from the reduced scenarios are probabilistically weighted in the objective function. We applied these three steps to a real district development in Cambridge, UK, and an illustrative district in Bangalore, India.Our results show that the technology investment portfolios derived from our 3-step methodology are more robust in meeting large possible variations in demand than any model optimised independently with a single demand scenario. This increased robustness comes at a higher monetary cost of investment. However, the high investment cost is lower than the highest possible cost when each of the initial 500 scenarios is optimised independently. In both our case studies, building level energy systems are always more robust than district level ones, a result which disagrees with many existing studies. The outcomes enable better examination of district energy systems. In addition, our methodology is compiled as an open-source code that can be applied to optimise existing and future energy masterplans of districts.