Maxwell-equations - the hard and the easy way

One can obtain Maxwell’s equations in two ways: write down a Lorentz-invariant Lagrange density first, vary and then fix the frame, or fix the frame first and vary afterwards. Under which conditions are the two operations commuting?