Alternatively, if you only need to compile without precleaning (e.g., for a one-off script), invoke the compiler directly ( cl.exe , link.exe ) instead of MSBuild.
: Invalid entries in the Windows registry pointing to old installation paths. Incomplete Uninstalls vs-preclean-vs.exe