From ae6e4cbe71d1a074488ccc84cf03e0386e069630 Mon Sep 17 00:00:00 2001 From: Rich Lander Date: Wed, 26 Oct 2016 15:33:11 -0700 Subject: [PATCH] Add scripts to accelerate NGEN compilation (#332) - Context: https://blogs.msdn.microsoft.com/dotnet/2013/08/06/wondering-why-mscorsvw-exe-has-high-cpu-usage-you-can-speed-it-up/ - The files were on a webserver before. Now, they will be more easily accessible --- tools/DrainNGENQueue/DrainNGenQueue.ps | 39 ++++++++ tools/DrainNGENQueue/DrainNGenQueue.wsf | 117 ++++++++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100644 tools/DrainNGENQueue/DrainNGenQueue.ps create mode 100644 tools/DrainNGENQueue/DrainNGenQueue.wsf diff --git a/tools/DrainNGENQueue/DrainNGenQueue.ps b/tools/DrainNGENQueue/DrainNGenQueue.ps new file mode 100644 index 0000000..1357853 --- /dev/null +++ b/tools/DrainNGENQueue/DrainNGenQueue.ps @@ -0,0 +1,39 @@ +# Script to force the .NET Framework optimization service to run at maximum speed. + +$isWin8Plus = [Environment]::OSVersion.Version -ge (new-object 'Version' 6,2) +$dotnetDir = [environment]::GetEnvironmentVariable("windir","Machine") + "\Microsoft.NET\Framework" +$dotnet2 = "v2.0.50727" +$dotnet4 = "v4.0.30319" + +$dotnetVersion = if (Test-Path ($dotnetDir + "\" + $dotnet4 + "\ngen.exe")) {$dotnet4} else {$dotnet2} + +$ngen32 = $dotnetDir + "\" + $dotnetVersion +"\ngen.exe" +$ngen64 = $dotnetDir + "64\" + $dotnetVersion +"\ngen.exe" +$ngenArgs = " executeQueuedItems" +$is64Bit = Test-Path $ngen64 + + +#32-bit NGEN -- appropriate for 32-bit and 64-bit machines +Write-Host("Requesting 32-bit NGEN") +Start-Process -wait $ngen32 -ArgumentList $ngenArgs + +#64-bit NGEN -- appropriate for 64-bit machines + +if ($is64Bit) { + Write-Host("Requesting 64-bit NGEN") + Start-Process -wait $ngen64 -ArgumentList $ngenArgs +} + +#AutoNGEN for Windows 8+ machines + +if ($isWin8Plus) { + Write-Host("Requesting 32-bit AutoNGEN -- Windows 8+") + schTasks /run /Tn "\Microsoft\Windows\.NET Framework\.NET Framework NGEN v4.0.30319" +} + +#64-bit AutoNGEN for Windows 8+ machines + +if ($isWin8Plus -and $is64Bit) { + Write-Host("Requesting 64-bit AutoNGEN -- Windows 8+") + schTasks /run /Tn "\Microsoft\Windows\.NET Framework\.NET Framework NGEN v4.0.30319 64" +} \ No newline at end of file diff --git a/tools/DrainNGENQueue/DrainNGenQueue.wsf b/tools/DrainNGENQueue/DrainNGenQueue.wsf new file mode 100644 index 0000000..abff566 --- /dev/null +++ b/tools/DrainNGENQueue/DrainNGenQueue.wsf @@ -0,0 +1,117 @@ + + +