Generally covariant gauge theories