I know that Ngen places its assemblies in C:\windows\assembly\NativesImages_*. But I also know that it keeps track of the references for each assembly so that if B and C depends on A then uninstalling B doesn't uninstall A. This makes me conclude that there are at least another location NGen uses to keep track of the reference count and any other related metadata, am I right?
The problem is that I am getting "Ngen error because Mscorlib.dll does not have a native image" and nothing gets optimized.
So as I expected, NGen uses the Windows Registry to do its book keeping. Adding the following exceptions solved my problem:
uwfmgr registry add-exclusion "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework"
uwfmgr registry add-exclusion "HKEY_LOCAL_MACHINE\SOTWARE\Microsoft\Net Framework Setup"