  Let $X$ be a compact manifold, $D$ a real elliptic operator on $X$, $G$ a Lie
group, $P\to X$ a principal $G$-bundle, and ${\mathcal B}_P$ the
infinite-dimensional moduli space of all connections $\nabla_P$ on $P$ modulo
gauge, as a topological stack. For each $[\nabla_P]\in{\mathcal B}_P$, we can
consider the twisted elliptic operator $D^{\nabla_{Ad(P)}}$ on X. This is a
continuous family of elliptic operators over the base ${\mathcal B}_P$, and so
has an orientation bundle $O^D_P\to{\mathcal B}_P$, a principal ${\mathbb
Z}_2$-bundle parametrizing orientations of
Ker$D^{\nabla_{Ad(P)}}\oplus$Coker$D^{\nabla_{Ad(P)}}$ at each $[\nabla_P]$. An
orientation on $({\mathcal B}_P,D)$ is a trivialization $O^D_P\cong{\mathcal
B}_P\times{\mathbb Z}_2$.
  In gauge theory one studies moduli spaces $\mathcal M$ of connections
$\nabla_P$ on $P$ satisfying some curvature condition, such as anti-self-dual
instantons on Riemannian 4-manifolds $(X, g)$. Under good conditions $\mathcal
M$ is a smooth manifold, and orientations on $({\mathcal B}_P,D)$ pull back to
orientations on $\mathcal M$ in the usual sense under the inclusion ${\mathcal
M}\hookrightarrow{\mathcal B}_P$. This is important in areas such as Donaldson
theory, where one needs an orientation on $\mathcal M$ to define enumerative
invariants.
  We explain a package of techniques, some known and some new, for proving
orientability and constructing canonical orientations on $({\mathcal B}_P,D)$,
after fixing some algebro-topological information on $X$. We use these to
construct canonical orientations on gauge theory moduli spaces, including new
results for moduli spaces of flat connections on 2- and 3-manifolds,
instantons, Kapustin-Witten and Vafa-Witten equations on 4-manifolds, and the
Haydys-Witten equations on 5-manifolds.
  Two sequels arXiv:1811.02405, arXiv:1811.09658 discuss orientations in 7 and
8 dimensions.
