Next-generation cellular networks will witness the creation of smart radio environments (SREs), where walls and objects can be coated with reconfigurable intelligent surfaces (RISs) to strengthen the communication and localization coverage by controlling the reflected multipath. In fact, RISs have been recently introduced not only to overcome communication blockages due to obstacles but also for high-precision localization of mobile users in GPS denied environments, e.g., indoors. Towards this vision, this paper presents the localization performance limits for communication scenarios where a single next generation NodeB base station (gNB), equipped with multiple-antennas, infers the position and the orientation of a user equipment (UE) in a RIS-assisted SRE. We consider a signal model that is valid also for near-field propagation conditions, as the usually adopted far-field assumption does not always hold, especially for large RISs. For the considered scenario, we derive the Cramer-Rao lower bound (CRLB) for assessing the ultimate localization and orientation performance of synchronous and asynchronous signaling schemes. In addition, we propose a closed-form RIS phase profile that well suits joint communication and localization, and we perform extensive numerical results to assess the performance of our scheme for various localization scenarios and for various RIS phase design. Numerical results show that the proposed scheme can achieve remarkable performance, even in asynchronous signaling and that the proposed phase design approaches the numerical optimal phase design that minimizes the CRLB.