Invariants of a lie algebra come from $\det(tI + a_i X_i)$, makes sense, you can get the Casimir, you can even get the electromagnetism invariant in the Lagrangian from this, but sticking the curvature form in there, $\det(tI + F)$ as in
i.stack.imgur.com/U6V8H.png wtf