Metal halide perovskites have shown unique advantages compared with traditional optoelectronic materials. Currently, perovskite films are commonly produced by either multi-step spin coating or vapor deposition techniques. However, both methods face challenges regarding large-scale production. Herein, we propose a straightforward in situ growth method for the fabrication of CsPbBr3 nanocrystal films. The films cover an area over 5.5 cm × 5.5 cm, with precise thickness control of a few microns and decent uniformity. Moreover, we demonstrate that the incorporation of magnesium ions into the perovskite enhances crystallization and effectively passivates surface defects, thereby further enhancing luminous efficiency. By integrating this approach with a silicon photodiode detector, we observe an increase in responsivity from 1.68 × 10−2 A/W to 3.72 × 10−2 A/W at a 365 nm ultraviolet wavelength.