The measurements of the production of prompt D , D +, D ∗ +, and Ds+ mesons in proton–proton (pp) collisions at s=5.02TeV with the ALICE detector at the Large Hadron Collider (LHC) are reported. D mesons were reconstructed at mid-rapidity (| y| < 0.5) via their hadronic decay channels D → K -π+, D +→ K -π+π+, D ∗ +→ D π+→ K -π+π+, Ds+→ϕπ+→K+K-π+, and their charge conjugates. The production cross sections were measured in the transverse momentum interval 0