It's the only thing that works. Compiling an installer (or signing one) is a process that involves writing an executable file to disk and then modifying it to add the actual installation payload and other operations such as signing. AV tools will often detect that an executable file has been written and then intercept and scan it, blocking further access to the file. If they're written well, subsequent operations will eventually complete and things will still work, but just slow down compilation. If they're not written well, subsequent operations will just fail. They are usually not written well.
There is no security risk in setting an exclusion on that folder, provided that you perform a manual scan on the folder before you run or distribute any of the files therein.