Aims. We aim to find a cosmologically motivated infall law to understand if the ΛCDM cosmology can reproduce the main chemical characteristics of a Milky Way-like spiral galaxy. Methods. We test several different gas infall laws, starting from that suggested in the two-infall model for the chemical evolution of the Milky Way, but focusing on laws derived from cosmological simulations which follows a concordance ΛCDM cosmology. By means of a detailed chemical evolution model for the solar vicinity, we study the effects of the different gas infall laws on the abundance patterns and the G-dwarf metallicity distribution. Results. The cosmological gas infall law, derived from dark matter halos having properties compatible with the formation of a disk galaxy like the Milky Way, and assuming that the baryons assemble like dark matter, resembles the infall law suggested by the twoinfall model. In particular, it predicts two main gas accretion episodes. Minor infall episodes are predicted to have followed the second main one but they are of little significance compared to the previous two. By means of this cosmologically motivated infall law, we study the star formation rate, the SNIa and SNII rate, the total amount of gas and stars in the solar neighbourhood and the behaviour of several chemical abundances. We find that the results of the two-infall model are fully compatible with the evolution of the Milky Way with cosmological accretion laws. We derive that the timescale for the formation of the stellar halo and the thick disk must have not been longer than 2 Gyr, whereas the disk in the solar vicinity assembled on a much longer timescale (∼6 Gyr). Conclusions. A gas assembly history derived from a DM halo, compatible with the formation of a late-type galaxy from the morphological point of view, can produce chemical properties in agreement with the available observations.