Magnetic flux ropes (MFRs) are believed to be the core structure in solar eruptions, nevertheless, their formation remains intensely debated. Here we report a rapid buildup process of an MFR-system during a confined X2.2 class flare occurred on 2017 September 6 in NOAA AR 12673, three hours after which the structure erupted to a major coronal mass ejection (CME) accompanied by an X9.3 class flare. For the X2.2 flare, we do not find EUV dimmings, separation of its flare ribbons, or clear CME signatures, suggesting a confined flare. For the X9.3 flare, large-scale dimmings, separation of its flare ribbons, and a CME show it to be eruptive. By performing a time sequence of nonlinear force-free fields (NLFFFs) extrapolations we find that: until the eruptive flare, an MFR-system was located in the AR. During the confined flare, the axial flux and the lower bound of the magnetic helicity for the MFR-system were dramatically enhanced by about 86% and 260%, respectively, although the mean twist number was almost unchanged. During the eruptive flare, the three parameters were all significantly reduced. The results evidence the buildup and release of the MFR-system during the confined and the eruptive flare, respectively. The former may be achieved by flare reconnection. We also calculate the pre-flare distributions of the decay index above the main polarity inversion line (PIL) and find no significant difference. It indicates that the buildup of the magnetic flux and helicity of the MFR-system may play a role in facilitating its final eruption.