The relative production rate of Bs0 and B0 mesons is determined with the hadronic decays Bs0→Ds−π+ and B0→D−K+. The measurement uses data corresponding to 1.0 fb−1 of pp collisions at a centre-of-mass energy of s=7 TeV recorded in the forward region with the LHCb experiment. The ratio of production rates, fs/fd, is measured to be 0.238±0.004±0.015±0.021, where the first uncertainty is statistical, the second systematic, and the third theoretical. This is combined with a previous LHCb measurement to obtain fs/fd=0.256±0.020. The dependence of fs/fd on the transverse momentum and pseudorapidity of the B meson is determined using the decays Bs0→Ds−π+ and B0→D−π+. There is evidence for a decrease with increasing transverse momentum, whereas the ratio remains constant as a function of pseudorapidity. In addition, the ratio of branching fractions of the decays B0→D−K+ and B0→D−π+ is measured to be 0.0822±0.0011(stat)±0.0025(syst).