Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit 1cf7eee

Browse files
KevinRansomnosami
authored andcommitted
Build FSI and FSC using AppHost (dotnet#10736)
* move over to fsc.dll and fsi.dll
1 parent d2c06ed commit 1cf7eee

File tree

9 files changed

+63
-38
lines changed

9 files changed

+63
-38
lines changed

FSharpTests.Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
<FscToolPath>$([System.IO.Path]::GetDirectoryName('$(DOTNET_HOST_PATH)'))</FscToolPath>
2323
<FscToolExe Condition="'$(OS)' != 'Unix'">dotnet.exe</FscToolExe>
2424
<FscToolExe Condition="'$(OS)' == 'Unix'">dotnet</FscToolExe>
25-
<DotnetFscCompilerPath>$(MSBuildThisFileDirectory)artifacts\bin\fsc\$(Configuration)\netcoreapp3.1\fsc.exe</DotnetFscCompilerPath>
25+
<DotnetFscCompilerPath>$(MSBuildThisFileDirectory)artifacts\bin\fsc\$(Configuration)\netcoreapp3.1\fsc.dll</DotnetFscCompilerPath>
2626

2727
<FsiToolPath>$([System.IO.Path]::GetDirectoryName('$(DOTNET_HOST_PATH)'))</FsiToolPath>
2828
<FsiToolExe Condition="'$(OS)' != 'Unix'">dotnet.exe</FsiToolExe>
2929
<FsiToolExe Condition="'$(OS)' == 'Unix'">dotnet</FsiToolExe>
30-
<DotnetFsiCompilerPath>$(MSBuildThisFileDirectory)artifacts\bin\fsi\$(Configuration)\netcoreapp3.1\fsi.exe</DotnetFsiCompilerPath>
30+
<DotnetFsiCompilerPath>$(MSBuildThisFileDirectory)artifacts\bin\fsi\$(Configuration)\netcoreapp3.1\fsi.dll</DotnetFsiCompilerPath>
3131
</PropertyGroup>
3232

3333
<!-- SDK targets override -->

eng/Build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ function Update-Arguments() {
163163
$script:bootstrap = $True
164164
}
165165
} else {
166-
if (-Not (Test-Path "$ArtifactsDir\Bootstrap\fsc\fsc.exe") -or (Test-Path "$ArtifactsDir\Bootstrap\fsc\fsc.runtimeconfig.json")) {
166+
if (-Not (Test-Path "$ArtifactsDir\Bootstrap\fsc\fsc.dll") -or (Test-Path "$ArtifactsDir\Bootstrap\fsc\fsc.runtimeconfig.json")) {
167167
$script:bootstrap = $True
168168
}
169169
}

src/buildtools/AssemblyCheck/AssemblyCheck.fs

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,52 @@ module AssemblyCheck =
1515
let private devVersionPattern = new Regex(@"-(ci|dev)", RegexOptions.Compiled)
1616

1717
let verifyEmbeddedPdb (filename:string) =
18-
use fileStream = File.OpenRead(filename)
19-
let reader = new PEReader(fileStream)
20-
let mutable hasEmbeddedPdb = false
21-
22-
try
23-
for entry in reader.ReadDebugDirectory() do
24-
match entry.Type with
25-
| DebugDirectoryEntryType.CodeView ->
26-
let _ = reader.ReadCodeViewDebugDirectoryData(entry)
27-
()
28-
29-
| DebugDirectoryEntryType.EmbeddedPortablePdb ->
30-
let _ = reader.ReadEmbeddedPortablePdbDebugDirectoryData(entry)
31-
hasEmbeddedPdb <- true
32-
()
33-
34-
| DebugDirectoryEntryType.PdbChecksum ->
35-
let _ = reader.ReadPdbChecksumDebugDirectoryData(entry)
36-
()
37-
38-
| _ -> ()
39-
with | e -> printfn "Error validating assembly %s\nMessage: %s" filename (e.ToString())
40-
hasEmbeddedPdb
18+
let isManagedDll =
19+
try
20+
// Is il assembly? throws if not
21+
let _ = AssemblyName.GetAssemblyName(filename).Version
22+
true
23+
with
24+
| :? System.BadImageFormatException -> false // uninterested in embedded pdbs for native dlls
25+
26+
if isManagedDll then
27+
use fileStream = File.OpenRead(filename)
28+
let reader = new PEReader(fileStream)
29+
let mutable hasEmbeddedPdb = false
30+
31+
try
32+
for entry in reader.ReadDebugDirectory() do
33+
match entry.Type with
34+
| DebugDirectoryEntryType.CodeView ->
35+
let _ = reader.ReadCodeViewDebugDirectoryData(entry)
36+
()
37+
38+
| DebugDirectoryEntryType.EmbeddedPortablePdb ->
39+
let _ = reader.ReadEmbeddedPortablePdbDebugDirectoryData(entry)
40+
hasEmbeddedPdb <- true
41+
()
42+
43+
| DebugDirectoryEntryType.PdbChecksum ->
44+
let _ = reader.ReadPdbChecksumDebugDirectoryData(entry)
45+
()
46+
47+
| _ -> ()
48+
with
49+
| e -> printfn "Error validating assembly %s\nMessage: %s" filename (e.ToString())
50+
51+
hasEmbeddedPdb
52+
else
53+
true
4154

4255
let verifyAssemblies (binariesPath:string) =
4356

4457
let excludedAssemblies =
4558
[ ] |> Set.ofList
4659

60+
let maybeNativeExe =
61+
[ "fsi.exe"
62+
"fsc.exe" ] |> Set.ofList
63+
4764
let fsharpAssemblies =
4865
[ "FSharp*.dll"
4966
"fsc.exe"
@@ -63,8 +80,12 @@ module AssemblyCheck =
6380
let failedVersionCheck =
6481
fsharpAssemblies
6582
|> List.filter (fun a ->
66-
let assemblyVersion = AssemblyName.GetAssemblyName(a).Version
67-
assemblyVersion = versionZero || assemblyVersion = versionOne)
83+
try
84+
let assemblyVersion = AssemblyName.GetAssemblyName(a).Version
85+
assemblyVersion = versionZero || assemblyVersion = versionOne
86+
with | :? System.BadImageFormatException ->
87+
// fsc.exe and fsi.exe are il on the desktop and native on the coreclr
88+
Set.contains (Path.GetFileName(a)) maybeNativeExe |> not)
6889

6990
if failedVersionCheck.Length > 0 then
7091
printfn "The following assemblies had a version of %A or %A" versionZero versionOne

src/fsharp/FSharp.Build/Microsoft.FSharp.NetSdk.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
5959
<PropertyGroup Condition="'$(DisableAutoSetFscCompilerPath)' != 'true' and '$(DOTNET_HOST_PATH)' != ''">
6060
<FscToolPath Condition="'$(FscToolPath)' == ''">$([System.IO.Path]::GetDirectoryName($(DOTNET_HOST_PATH)))</FscToolPath>
6161
<FscToolExe Condition="'$(FscToolExe)' == ''">$([System.IO.Path]::GetFileName($(DOTNET_HOST_PATH)))</FscToolExe>
62-
<DotnetFscCompilerPath Condition="'$(DotnetFscCompilerPath)' == ''">"$(MSBuildThisFileDirectory)fsc.exe"</DotnetFscCompilerPath>
62+
<DotnetFscCompilerPath Condition="'$(DotnetFscCompilerPath)' == ''">"$(MSBuildThisFileDirectory)fsc.dll"</DotnetFscCompilerPath>
6363

6464
<FsiToolPath Condition="'$(FsiToolPath)' == ''">$([System.IO.Path]::GetDirectoryName($(DOTNET_HOST_PATH)))</FsiToolPath>
6565
<FsiToolExe Condition="'$(FsiToolExe)' == ''">$([System.IO.Path]::GetFileName($(DOTNET_HOST_PATH)))</FsiToolExe>
66-
<DotnetFsiCompilerPath Condition="'$(DotnetFscCompilerPath)' == ''">"$(MSBuildThisFileDirectory)fsi.exe"</DotnetFsiCompilerPath>
66+
<DotnetFsiCompilerPath Condition="'$(DotnetFscCompilerPath)' == ''">"$(MSBuildThisFileDirectory)fsi.dll"</DotnetFsiCompilerPath>
6767
</PropertyGroup>
6868

6969
<ItemGroup Condition="'$(DisableImplicitSystemValueTupleReference)' != 'true'

src/fsharp/Microsoft.FSharp.Compiler/Microsoft.FSharp.Compiler.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
this approach gives a very small deployment. Which is kind of necessary.
4747
-->
4848
<!-- assemblies -->
49-
<file src="fsc\$Configuration$\netcoreapp3.1\fsc.exe" target="lib\netcoreapp3.1" />
50-
<file src="fsi\$Configuration$\netcoreapp3.1\fsi.exe" target="lib\netcoreapp3.1" />
49+
<file src="fsc\$Configuration$\netcoreapp3.1\fsc.dll" target="lib\netcoreapp3.1" />
50+
<file src="fsi\$Configuration$\netcoreapp3.1\fsi.dll" target="lib\netcoreapp3.1" />
5151
<file src="FSharp.Core\$Configuration$\netstandard2.0\FSharp.Core.dll" target="lib\netcoreapp3.1" />
5252
<file src="FSharp.Core\$Configuration$\netstandard2.0\FSharp.Core.xml" target="lib\netcoreapp3.1" />
5353
<file src="FSharp.Compiler.Private\$Configuration$\netstandard2.0\FSharp.Compiler.Private.dll" target="lib\netcoreapp3.1" />

src/fsharp/fsc/fsc.fsproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
<TargetFrameworks Condition="'$(OS)' == 'Unix'">netcoreapp3.0</TargetFrameworks>
1313
<TargetFrameworks Condition="'$(ProtoTargetFramework)' == ''">net472;netcoreapp3.1</TargetFrameworks>
1414
<TargetFrameworks Condition="'$(OS)' == 'Unix'">netcoreapp3.1</TargetFrameworks>
15-
<TargetExt>.exe</TargetExt>
1615
<NoWarn>$(NoWarn);45;55;62;75;1204</NoWarn>
1716
<AllowCrossTargeting>true</AllowCrossTargeting>
1817
<OtherFlags>$(OtherFlags) --maxerrors:20 --extraoptimizationloops:1</OtherFlags>
1918
<NGenBinary>true</NGenBinary>
20-
<UseAppHost>false</UseAppHost>
19+
<UseAppHost>true</UseAppHost>
2120
</PropertyGroup>
2221

2322
<PropertyGroup Condition="'$(TargetFramework)' == 'net472'">

src/fsharp/fsi/fsi.fsproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@
1212
<TargetFrameworks Condition="'$(OS)' == 'Unix'">netcoreapp3.0</TargetFrameworks>
1313
<TargetFrameworks Condition="'$(ProtoTargetFramework)' == ''">net472;netcoreapp3.1</TargetFrameworks>
1414
<TargetFrameworks Condition="'$(OS)' == 'Unix'">netcoreapp3.1</TargetFrameworks>
15-
<TargetExt>.exe</TargetExt>
1615
<NoWarn>$(NoWarn);45;55;62;75;1204</NoWarn>
1716
<AllowCrossTargeting>true</AllowCrossTargeting>
1817
<OtherFlags>--warnon:1182 --maxerrors:20 --extraoptimizationloops:1</OtherFlags>
1918
<Win32Resource>fsi.res</Win32Resource>
2019
<NGenBinary>true</NGenBinary>
21-
<UseAppHost>false</UseAppHost>
20+
<UseAppHost>true</UseAppHost>
2221
</PropertyGroup>
2322

2423
<PropertyGroup Condition="'$(TargetFramework)' == 'net472'">

tests/FSharp.Test.Utilities/CompilerAssert.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ let main argv = 0"""
239239
let args =
240240
options
241241
|> Array.append defaultProjectOptions.OtherOptions
242-
|> Array.append [| "fsc.exe"; inputFilePath; "-o:" + outputFilePath; (if isExe then "--target:exe" else "--target:library"); "--nowin32manifest" |]
242+
|> Array.append [| "fsc.dll"; inputFilePath; "-o:" + outputFilePath; (if isExe then "--target:exe" else "--target:library"); "--nowin32manifest" |]
243243
let errors, _ = checker.Compile args |> Async.RunSynchronously
244244
errors, outputFilePath
245245

tests/FSharp.Test.Utilities/TestFramework.fs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,19 @@ let config configurationName envVars =
293293
if File.Exists(repoLocalDotnetPath) then repoLocalDotnetPath
294294
else DOTNET_EXE
295295

296+
#if !NETCOREAPP
296297
let FSI_PATH = ("fsi" ++ configurationName ++ fsiArchitecture ++ "fsi.exe")
298+
#else
299+
let FSI_PATH = ("fsi" ++ configurationName ++ fsiArchitecture ++ "fsi.dll")
300+
#endif
297301
let FSI_FOR_SCRIPTS = requireArtifact FSI_PATH
298302
let FSI = requireArtifact FSI_PATH
299303
#if !NETCOREAPP
300304
let FSIANYCPU = requireArtifact ("fsiAnyCpu" ++ configurationName ++ "net472" ++ "fsiAnyCpu.exe")
301-
#endif
302305
let FSC = requireArtifact ("fsc" ++ configurationName ++ fscArchitecture ++ "fsc.exe")
306+
#else
307+
let FSC = requireArtifact ("fsc" ++ configurationName ++ fscArchitecture ++ "fsc.dll")
308+
#endif
303309
let FSCOREDLLPATH = requireArtifact ("FSharp.Core" ++ configurationName ++ fsharpCoreArchitecture ++ "FSharp.Core.dll")
304310

305311
let defaultPlatform =

0 commit comments

Comments
 (0)