I am posting this here, in case anyone else bumps into this problem. I lost a full day of productivity until I figured it out.
I have a very large DNN solution with multiple projects, all built based on the Christoc DNN Visual Studio template. My issue only started happening after one particular project grew to a certain point. It would compile just fine in debug mode, but in release mode the build would hang almost immediately. The only way out of it was to kill the Visual Studio process, reboot, and then delete all of the temporary files and folders that were created by the msbuild script.
These were all things that normally the build cleans up by itself after creating the _install and _source zip files, but when the build would hang all of those things (including multiple .tmp files) would be left behind. At least some of the files would also be deadlocked, and could not be deleted without a reboot.
After a full day of frustration and troubleshooting, I finally discovered that things were getting deadlocked during one of the zip directives in the msbuild script. If you look at BuildScripts\ModulePackage.targets you will see several elements that are all similar to:
<zip files="@(ResourcesContent)" workingdirectory="$(MSBuildProjectDirectory)\ResourcesZip" zipfilename="Resources.$(Extension)" />
What I had to do to get my build working again was to turn off parallel compression in all of the zip directives, so I changed them to look like:
<zip files="@(ResourcesContent)" workingdirectory="$(MSBuildProjectDirectory)\ResourcesZip" zipfilename="Resources.$(Extension)" ParallelCompression="false" />
After adding that attribute to all four places, my build went back to working correctly.
I don't know what specifically caused the zip process to suddenly start deadlocking on my dev machine. I was able to open the exact same source code on another system and build without issue, even without adding that attribute to the msbuild script. Still, that is what fixed the problem on the affected machine.
So, for anyone who is banging their head against the wall trying to figure out why all of a sudden their build hangs with the (very excellent) Christoc templates, please give this a shot. I hope it works for you as well.