  In this paper we recover the non-perturbative partition function of
2D~Yang-Mills theory from the perturbative path integral. To achieve this goal,
we study the perturbative path integral quantization for 2D~Yang-Mills theory
on surfaces with boundaries and corners in the Batalin-Vilkovisky formalism
(or, more precisely, in its adaptation to the setting with boundaries,
compatible with gluing and cutting -- the BV-BFV formalism). We prove that
cutting a surface (e.g. a closed one) into simple enough pieces -- building
blocks -- and choosing a convenient gauge-fixing on the pieces, and assembling
back the partition function on the surface, one recovers the known
non-perturbative answers for 2D~Yang-Mills theory.
