Skip to content

Commit c4eef3a

Browse files
KevinRansombaronfel
authored andcommitted
Re-enable ngen for desktop compiler builds (#6386)
* Re-enable ngen for desktop compilers * Go even earlier * Cooler mechanism
1 parent 7503f44 commit c4eef3a

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

FSharpBuild.Directory.Build.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
2-
32
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
43
<Import Project="eng\targets\NuGet.targets" />
4+
<Import Project="eng\targets\NGenBinaries.targets" />
55
<Import Project="FSharp.Profiles.props" />
66

77
<PropertyGroup Condition="'$(UseAssetTargetFallback)' == 'true'">

eng/targets/NGenBinaries.targets

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<Project>
2+
3+
<!-- Windows permissions means that users can't even see the directory $(SystemRoot)System32\config -->
4+
<PropertyGroup Condition="'$(OS)' != 'Unix' AND Exists('$(SystemRoot)\System32\config\system')">
5+
<IsAdministrator>true</IsAdministrator>
6+
<DelaySign>true</DelaySign>
7+
<PublicSign>false</PublicSign>
8+
</PropertyGroup>
9+
10+
<Target Name="NGenWindowsBinaries"
11+
AfterTargets="AfterBuild"
12+
Condition="'$(OS)' != 'Unix' AND
13+
$(TargetFramework.StartsWith('net4')) AND
14+
'$(NGenBinary)' == 'true' AND
15+
Exists('$(TargetPath)') ">
16+
<PropertyGroup>
17+
<PathToNGen64>$(windir)\Microsoft.NET\Framework64\v4.0.30319\ngen.exe</PathToNGen64>
18+
<PathToNGen32>$(windir)\Microsoft.NET\Framework\v4.0.30319\ngen.exe</PathToNGen32>
19+
<PathToSN32>$(WindowsSDK_ExecutablePath_x86)sn.exe</PathToSN32>
20+
</PropertyGroup>
21+
22+
<!--
23+
Enable Skip Verification and then NGen for both 32 and 64 bit product.
24+
If compiling use the app config file, if present.
25+
-->
26+
<Exec Command='"$(PathToSN32)" /Vr "$(TargetPath)"' Condition = "Exists('$(PathToSN32)') AND Exists('$(TargetPath)') AND '$(IsAdministrator)' == 'true'"/>
27+
28+
<Exec Command='"$(PathToNGen64)" install "$(TargetPath)" /ExeConfig:$(TargetPath)' Condition = "Exists('$(PathToNGen64)') AND '$(PlatformTarget)' != 'x86' AND Exists('$(TargetPath).config') AND '$(IsAdministrator)' == 'true'"/>
29+
<Exec Command='"$(PathToNGen32)" install "$(TargetPath)" /ExeConfig:$(TargetPath)' Condition = "Exists('$(PathToNGen32)') AND '$(PlatformTarget)' != 'x64' AND Exists('$(TargetPath).config') AND '$(IsAdministrator)' == 'true'"/>
30+
<Exec Command='"$(PathToNGen64)" install "$(TargetPath)"' Condition = " Exists('$(PathToNGen64)') AND '$(PlatformTarget)' != 'x86' AND (!Exists('$(TargetPath).config')) AND '$(IsAdministrator)' == 'true' "/>
31+
<Exec Command='"$(PathToNGen32)" install "$(TargetPath)"' Condition = " Exists('$(PathToNGen32)') AND '$(PlatformTarget)' != 'x64' AND (!Exists('$(TargetPath).config')) AND '$(IsAdministrator)' == 'true' "/>
32+
</Target>
33+
</Project>

src/fsharp/fsiAnyCpu/fsiAnyCpu.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<OtherFlags>$(OtherFlags) --warnon:1182 --maxerrors:20 --extraoptimizationloops:1</OtherFlags>
1313
<Win32Resource>..\fsi\fsi.res</Win32Resource>
1414
<UseAssetTargetFallback>true</UseAssetTargetFallback>
15+
<NGenBinary>true</NGenBinary>
1516
</PropertyGroup>
1617

1718
<PropertyGroup>

0 commit comments

Comments
 (0)