Let \(G\)  be a compact semi-simple Lie group with Lie algebra
\(\mathfrak {g}\) , and
\(\varphi \colon G \longrightarrow G\) 
an outer automorphism of \(G\) . In this section we construct a groupoid homomorphism
\(\varphi \colon \mathsf {Bun}_G^\nabla (\Sigma ) \longrightarrow \mathsf {Bun}_G^\nabla (\Sigma )\)  on the topological groupoid of principal \(G\) -bundles with connection for every closed
oriented surface \(\Sigma \) . We show in
Section REF  that the Yang-Mills action functional on \(\Sigma \)  is invariant under this
transformation, so that \(\varphi \)  defines a symmetry of the gauge theory. In Section REF  we study the
corresponding defects in terms of twisted bundles, and calculate the
partition functions exactly
using a lattice
regularisation of the quantum gauge theory in Section REF .
The partition function for
a given defect configuration localises in the weak-coupling limit onto
the moduli space of flat twisted \(G\) -bundles, similarly to the
untwisted case [1]}. In this limit the
partition function computes the symplectic volume of this moduli space, defined for example in [2]}. We will
use the combinatorial quantisation of two-dimensional Yang-Mills theory to make a precise conjecture for this volume in some simple cases in Section REF . In Section REF 
we compute the corresponding orbifold theory, and subsequently the
reverse orbifold theory in Section REF .
