Based on Mermin's extension of the Hohenberg and Kohn theorems to non-zero temperature, the Kohn-Sham formulation of density functional theory (KS-DFT) is generalized to finite temperature. We show that present formulations are inconsistent with Mermin's functional containing expressions, in particular describing the Coulomb energy, that defy derivation and are even in violation of rules of logical inference. More; current methodology is in violation of fundamental laws of both quantum and classical mechanics. Based on this feature, we demonstrate the impossibility of extending the KS formalism to finite temperature through the self-consistent solutions of the single-particle Schrödinger equation of T>0. Guided by the form of Mermin's functional that depends on the eigenstates of a Hamiltonian, determined at T=0, we base our extension of KS-DFT on the determination of the excited states of a non-interacting system at the zero of temperature. The resulting formulation is consistent with that of Mermin constructing the free energy at T>0 in terms of the excited states of a non-interacting Hamiltonian (system) that, within the KS formalism, are described by Slater determinants. To determine the excited states at T=0 use is made of the extension of the Hohenberg and Kohn theorems to excited states presented in previous work applied here to a non-interacting collection of replicas of a non-interacting N-particle system, whose ground state density is taken to match that of K non-interacting replicas of an interacting N-particle system at T=0. The formalism allows for an ever denser population of the excitation spectrum of a Hamiltonian, within the KS approximation. The form of the auxiliary potential, (Kohn-Sham potential), is formally identical to that in the ground state formalism with the contribution of the Coulomb energy provided by the derivative of the Coulomb energy in all excited states taken into account. Once the excited states are determined, the minimum of the free energy within the KS formalism follows immediately in the form of Mermin's functional, but with the exact excited states in that functional represented by Slater determinants obtained through self-consistency conditions at the zero of temperature. It is emphasized that, in departure from all existing formulations, no self-consistency conditions are implemented at finite T; as we show, in fact, such formulations are rigorously blocked.