Review/Fix MSBuild ngen registrations
Context
Reported by @davkean:
Its super unclear why all MSBuild binaries in general are being registered for all architectures too (we only should register 32-bit for 32-bit and 64-bit for 64-bit), those 32-bit vsn.exe are definitely wrong as we don’t ship a 32-bit version of VS, so we’re wasting end-user machine resources.
Goal
Only required registrations are issued
Sub-issue https://github.com/dotnet/msbuild/issues/10847
Looking at this as part of #11145, and I think we need Setup features or a pretty big package refactor to do it right.
Specifically, we want our core assemblies and their transitive closure to be ngened in several contexts:
| Context | controlling config | arch | file |
|---|---|---|---|
| VS in-proc | vsn.exe |
amd64 or arm64 | bin\Microsoft.Build*.dllclosure |
| Mainline CLI | bin\amd64\MSBuild.exe |
amd64 | bin\amd64\MSBuild.exebin\Microsoft.Build*.dllclosure |
| Old CLI and 32-bit taskhost | bin\MSBuild.exe |
x86 | bin\MSBuild.exebin\Microsoft.Build*.dllclosure |
| arm64 CLI | bin\arm64\MSBuild.exe |
arm64 | bin\arm64\MSBuild.exebin\Microsoft.Build*.dllclosure |
But I don't see a way to express in the .swr or the VSIX manifest things like "ngen bin\Microsoft.Build.dll for amd64 with bin\amd64\MSBuild.exe.config and vsn.config and also for x86 with bin\MSBuild.exe.config".
Today, we run:
[framework]
install "C:\VisualStudio\MSBuild\Current\Bin\Microsoft.Build.dll" /NoDependencies /ExeConfig:"C:\VisualStudio\MSBuild\Current\Bin\MSBuild.exe" /queue:1
install "C:\VisualStudio\MSBuild\Current\Bin\Microsoft.Build.dll" /NoDependencies /ExeConfig:"C:\VisualStudio\Common7\IDE\vsn.exe" /queue:1
[framework64]
install "C:\VisualStudio\MSBuild\Current\Bin\Microsoft.Build.dll" /NoDependencies /ExeConfig:"C:\VisualStudio\Common7\IDE\vsn.exe" /queue:1
install "C:\VisualStudio\MSBuild\Current\Bin\Microsoft.Build.dll" /NoDependencies /ExeConfig:"C:\VisualStudio\MSBuild\Current\Bin\MSBuild.exe" /queue:1
- the 32-bit
vsn.exeone is unnecessary - 32-bit msbuild.exe is important for CI
- 64-bit
vsn.exeis critical - 64-bit
msbuild.exeis critical (but is it getting the right context here? At runtime it'll getbin\amd64\MSBuild.exe.configbut it's running with justbin\MSBuild.exe.config)
reverted https://github.com/dotnet/msbuild/pull/11182 which contributed to this:
Regresses VM_AdjustedImagesInMemory_Total_devenv e.g. here: https://devdiv.visualstudio.com/DevDiv/_git/VS/pullrequest/606301