We have investigated the preparation of NiO layers by cathodic electrodeposition in various organic-based solvents, namely ethanol, dimethyl sulfoxide (DMSO), DMSO/2 vol.% H2O and DMSO/25 vol.% H2O mixtures. The layers were formed from the electrochemical reduction of nickel nitrate precursor. We show that, depending on the solvent used, various nickel compounds were deposited. In the case of ethanol, a transparent precursor layer was obtained that was transformed into NiO after an annealing treatment at 300°C. For DMSO and DMSO with 2 volume % of H2O, adherent, well-covering, mesoporous and rather thick NiO layers were obtained after an annealing treatment at 450°C. These layers, after growth, contained nickel oxide or hydroxide, metallic nickel and DMSO. The solvent acted as a blowing agent, being included in the deposit and giving rise to a mesoporous film after its elimination by thermal annealing. These porous layers of p-type oxide have been successfully sensitized by a push-pull dye (P1 dye) and showed photocurrent generation and an open circuit voltage (Voc) up to 167 mV in p-type dye-sensitized solar cells (p-DSSCs). For DMSO with 25 volume % of H2O, the deposited layers contained more metallic nickel and were dense even after annealing. They were unsuitable in p-DSSCs.