Let P → M be a principal G-bundle over a pseudo-Riemannian manifold (M, g). If G is semisimple, the Euler-Lagrange and the Hamilton-Cartan equations of the Yang-Mills Lagrangian defined by g are proved to remain unchanged if the Cartan-Killing metric is replaced by any other non-degenerate, adjoint-invariant bilinear form on the Lie algebra 𝔤. Moreover, it is shown that the Hamilton-Cartan equations for any gauge invariant problem are essentially the same as their Euler-Lagrange equations if some simple regularity assumption is made. Actually, the set of solutions to Hamilton equations trivially fibers over the set of extremals of the variational problem.