Error MSB6006: "mt.exe" exited with code 31

WARNING: This exact error can also happen as a result of having a Windows Explorer window open in the folder containing the *.exe which you are currently attempting to build.

For example: Explorer open in /.../MyProj/Debug/ while trying to build the Debug version of your code in Visual Studio.

I was angry with myself for ~10min before realizing this.


Using process monitor and dbgview I discovered msmpeng (Microsoft Security Essentials) was accessing the file, just when mt.exe wanted to have it exclusively. Excluding the development directory solved the problem. It is still a workaround of course.