Skip to content

Commit

Permalink
Performance fixes II - ngen binaries (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-garcia-garcia authored Aug 4, 2024
1 parent 09e425b commit 748daa1
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions servercore2022/dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,42 @@
# escape=`
FROM mcr.microsoft.com/windows/servercore:ltsc2022

# https://github.com/microsoft/dotnet-framework-docker/blob/main/src/runtime/4.8.1/windowsservercore-ltsc2022/Dockerfile
ENV `
# Enable detection of running in a container
DOTNET_RUNNING_IN_CONTAINER=true `
COMPLUS_RUNNING_IN_CONTAINER=1 `
COMPLUS_NGenProtectedProcess_FeatureEnabled=0

# https://github.com/microsoft/dotnet-framework-docker/blob/main/src/runtime/4.8/windowsservercore-ltsc2022/Dockerfile
RUN `
# Ngen top of assembly graph to optimize a set of frequently used assemblies
%windir%\Microsoft.NET\Framework64\v4.0.30319\ngen install "Microsoft.PowerShell.Utility.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" `
# To optimize 32-bit assemblies, uncomment the next line
# && %windir%\Microsoft.NET\Framework\v4.0.30319\ngen install "Microsoft.PowerShell.Utility.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" `
&& %windir%\Microsoft.NET\Framework64\v4.0.30319\ngen update `
&& %windir%\Microsoft.NET\Framework\v4.0.30319\ngen update

# Install 2.9.0 Roslyn compilers
RUN curl -fSLo microsoft.net.compilers.2.9.0.zip https://api.nuget.org/packages/microsoft.net.compilers.2.9.0.nupkg `
&& mkdir C:\RoslynCompilers `
&& tar -C C:\RoslynCompilers -zxf microsoft.net.compilers.2.9.0.zip `
&& del microsoft.net.compilers.2.9.0.zip `
&& %windir%\Microsoft.NET\Framework64\v4.0.30319\ngen install C:\RoslynCompilers\tools\csc.exe /ExeConfig:C:\RoslynCompilers\tools\csc.exe `
&& %windir%\Microsoft.NET\Framework64\v4.0.30319\ngen install C:\RoslynCompilers\tools\vbc.exe /ExeConfig:C:\RoslynCompilers\tools\vbc.exe `
&& %windir%\Microsoft.NET\Framework64\v4.0.30319\ngen install C:\RoslynCompilers\tools\VBCSCompiler.exe /ExeConfig:C:\RoslynCompilers\tools\VBCSCompiler.exe

# Install 3.6.0 Roslyn compilers
RUN curl -fSLo microsoft.net.compilers.3.6.0.zip https://api.nuget.org/packages/microsoft.net.compilers.3.6.0.nupkg `
&& mkdir C:\RoslynCompilers-3.6.0 `
&& tar -C C:\RoslynCompilers-3.6.0 -zxf microsoft.net.compilers.3.6.0.zip `
&& del microsoft.net.compilers.3.6.0.zip `
&& %windir%\Microsoft.NET\Framework64\v4.0.30319\ngen install C:\RoslynCompilers-3.6.0\tools\csc.exe /ExeConfig:C:\RoslynCompilers-3.6.0\tools\csc.exe `
&& %windir%\Microsoft.NET\Framework64\v4.0.30319\ngen install C:\RoslynCompilers-3.6.0\tools\vbc.exe /ExeConfig:C:\RoslynCompilers-3.6.0\tools\vbc.exe `
&& %windir%\Microsoft.NET\Framework64\v4.0.30319\ngen install C:\RoslynCompilers-3.6.0\tools\VBCSCompiler.exe /ExeConfig:C:\RoslynCompilers-3.6.0\tools\VBCSCompiler.exe

ENV ROSLYN_COMPILER_LOCATION=C:\RoslynCompilers-3.6.0\tools

SHELL ["powershell.exe"]

RUN $global:ErrorActionPreference = 'Stop'; `
Expand Down

0 comments on commit 748daa1

Please sign in to comment.