GUILDERLAND — After five years of planning and legal battles, the Capital Region's first Costco is expected to be built by the end of the year.