Easy. Detect when the build order is issued (yes it issues an order before it starts to build the building) and then simply cancle the build order. Next create a dummy summoner (or move a recycled one to do the job) and get him to build the building by issuing the same order at the same position. Alternativly you deduct the resources and just spawn the building (again via triggers).
Its that simple. . .
Note that you may need to mess around with orders and unit parameters until you get a result which feels pollished enough to use.
or u can make it by zones, make a zone where u want the building to be made, then make a trigger, that when u make an upgrade or whatever, a unit (building) spawns on the area