rgl / windows-vagrant

Windows 11/2022/2025 Base Vagrant Box (https://app.vagrantup.com/rgl)
MIT License
362 stars 95 forks source link

Run .NET Runtime Optimization (ngen) #9

Closed project0 closed 4 years ago

project0 commented 4 years ago

Hey there, your stuff was a nice knowledge base for me to build windows ami with packer. You might also want to include forcing the .NET compiler to run after installation. This is what i use before sysprep the image (in my case EC2 AMI):

  ## Force .NET Runtime Optimization service (mscorsvw.exe) to run compiler now (usually required after updates and installations)
  # running it now prevents compiling on each started ec2 instance based on it
  # Run for all archs (32 and 64 bit) and versions
  Get-Item  $([environment]::GetEnvironmentVariable("windir","Machine") + "\Microsoft.NET\*\*\ngen.exe") | ForEach-Object {
    Start-Process -NoNewWindow -PassThru -Wait -FilePath $_.FullName -ArgumentList "executeQueuedItems /silent"
  }
rgl commented 4 years ago

Not so long ago the https://github.com/rgl/windows-vagrant/blob/e61725f6938cf040f2fbf143863f65ad288656d6/optimize.ps1#L89-L91 step also triggered that, but for some reason it no longer does :-/

I will incorporate a ngen step. Thanks for pointing that out!

rgl commented 4 years ago

Done at https://github.com/rgl/windows-vagrant/commit/720555a74d3697c63b2de02f00b0db98e03f49a0.