Skip to content

Commit 2f737f8

Browse files
authored
Merge pull request #588 from dsyme/fix-paths-1
Adjust search paths
2 parents 3438b3c + 13be70f commit 2f737f8

File tree

2 files changed

+19
-71
lines changed

2 files changed

+19
-71
lines changed

src/fsharp/CompileOps.fs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2779,24 +2779,28 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
27792779
let facades = Path.Combine(api, "Facades")
27802780
if Directory.Exists(facades) then
27812781
yield facades
2782-
else
2783-
yield runtimeRoot
2784-
let facades = Path.Combine(runtimeRoot, "Facades")
2785-
if Directory.Exists(facades) then
2786-
yield facades
2782+
yield runtimeRoot // The defaut FSharp.Core is found in lib/mono/4.5
2783+
let facades = Path.Combine(runtimeRoot, "Facades")
2784+
if Directory.Exists(facades) then
2785+
yield facades
27872786
]
27882787
else
27892788
#endif
27902789
try
2790+
[
27912791
match tcConfig.resolutionEnvironment with
27922792
#if FX_MSBUILDRESOLVER_RUNTIMELIKE
27932793
| MSBuildResolver.RuntimeLike ->
2794-
[System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()]
2794+
yield System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
27952795
#endif
27962796
| _ ->
2797-
let frameworkRoot = MSBuildResolver.DotNetFrameworkReferenceAssembliesRootDirectoryOnWindows
2798-
let frameworkRootVersion = Path.Combine(frameworkRoot,tcConfig.targetFrameworkVersionMajorMinor)
2799-
[frameworkRootVersion]
2797+
let frameworkRoot = MSBuildResolver.DotNetFrameworkReferenceAssembliesRootDirectoryOnWindows
2798+
let frameworkRootVersion = Path.Combine(frameworkRoot,tcConfig.targetFrameworkVersionMajorMinor)
2799+
yield frameworkRootVersion
2800+
let facades = Path.Combine(frameworkRootVersion, "Facades")
2801+
if Directory.Exists(facades) then
2802+
yield facades
2803+
]
28002804
with e ->
28012805
errorRecovery e range0; []
28022806

src/fsharp/ReferenceResolution.fs

Lines changed: 6 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,9 @@ module internal MSBuildResolver =
139139
/// The list of supported .NET Framework version numbers, using the monikers of the Reference Assemblies folder.
140140
let SupportedNetFrameworkVersions = set [ Net20; Net30; Net35; Net40; Net45; Net451; (*SL only*) "v5.0" ]
141141

142-
#if CROSS_PLATFORM_COMPILER
143-
// Mono doesn't have GetPathToDotNetFramework. In this case we simply don't search this extra directory.
144-
// When the x-plat compiler is run on Mono this is ok since implementation assembly folder is the same as the target framework folder.
145-
// When the x-plat compiler is run on Windows/.NET this will curently cause slightly divergent behaviour.
146-
let GetPathToDotNetFrameworkImlpementationAssemblies _v = []
147-
#else
148142
/// Get the path to the .NET Framework implementation assemblies by using ToolLocationHelper.GetPathToDotNetFramework.
149143
/// This is only used to specify the "last resort" path for assembly resolution.
150144
let GetPathToDotNetFrameworkImlpementationAssemblies(v) =
151-
#if FX_ATLEAST_45
152145
let v =
153146
match v with
154147
| Net11 -> Some TargetDotNetFrameworkVersion.Version11
@@ -165,61 +158,18 @@ module internal MSBuildResolver =
165158
| null -> []
166159
| x -> [x]
167160
| _ -> []
168-
#else
169-
// FX_ATLEAST_45 is not defined for step when we build compiler with proto compiler.
170-
ignore v
171-
[]
172-
#endif
173-
#endif
174-
175-
176-
#if CROSS_PLATFORM_COMPILER
177-
// ToolLocationHelper.GetPathToDotNetFrameworkReferenceAssemblies is not available on Mono.
178-
// We currently use the old values that the F# 2.0 compiler assumed.
179-
// When the x-plat compiler is run on Mono this is ok since the asemblies are all in the framework folder
180-
// When the x-plat compiler is run on Windows/.NET this will curently cause slightly divergent behaviour this directory
181-
// may not be the same as the Microsoft compiler in all cases.
182-
let GetPathToDotNetFrameworkReferenceAssembliesFor40Plus(version) =
183-
match version with
184-
| Net40 -> ReplaceVariablesForLegacyFxOnWindows([@"{ReferenceAssemblies}\v4.0"])
185-
| Net45 -> ReplaceVariablesForLegacyFxOnWindows([@"{ReferenceAssemblies}\v4.5"])
186-
| Net451 -> ReplaceVariablesForLegacyFxOnWindows([@"{ReferenceAssemblies}\v4.5"])
187-
| _ -> []
188-
#else
189161

190-
let GetPathToDotNetFrameworkReferenceAssembliesFor40Plus(version) =
191-
#if FX_ATLEAST_45
192-
// starting with .Net 4.0, the runtime dirs (WindowsFramework) are never used by MSBuild RAR
193-
let v =
194-
match version with
195-
| Net40 -> Some TargetDotNetFrameworkVersion.Version40
196-
| Net45 -> Some TargetDotNetFrameworkVersion.Version45
197-
| Net451 -> Some TargetDotNetFrameworkVersion.Version451
198-
| _ -> assert false; None // unknown version - some parts in the code are not synced
199-
match v with
200-
| Some v ->
201-
match ToolLocationHelper.GetPathToDotNetFrameworkReferenceAssemblies v with
202-
| null -> []
203-
| x -> [x]
204-
| None -> []
205-
#else
206-
// FX_ATLEAST_45 is not defined for step when we build compiler with proto compiler.
207-
ignore version
208-
[]
209-
#endif
210-
#endif
211162

212-
#if CROSS_PLATFORM_COMPILER
213-
let HighestInstalledNetFrameworkVersionMajorMinor() =
214-
// Mono doesn't have GetPathToDotNetFramework
215-
4, Net40
216-
#else
163+
let GetPathToDotNetFrameworkReferenceAssemblies(version) =
164+
match Microsoft.Build.Utilities.ToolLocationHelper.GetPathToStandardLibraries(".NETFramework",version,"") with
165+
| null | "" -> []
166+
| x -> [x]
167+
217168
/// Use MSBuild to determine the version of the highest installed framework.
218169
let HighestInstalledNetFrameworkVersionMajorMinor() =
219170
if box (ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version451)) <> null then 4, Net451
220171
elif box (ToolLocationHelper.GetPathToDotNetFramework(TargetDotNetFrameworkVersion.Version45)) <> null then 4, Net45
221172
else 4, Net40 // version is 4.0 assumed since this code is running.
222-
#endif
223173

224174
/// Derive the target framework directories.
225175
let DeriveTargetFrameworkDirectories (targetFrameworkVersion:string, logMessage) =
@@ -228,13 +178,7 @@ module internal MSBuildResolver =
228178
if not(targetFrameworkVersion.StartsWith("v",StringComparison.Ordinal)) then "v"+targetFrameworkVersion
229179
else targetFrameworkVersion
230180

231-
let result =
232-
if targetFrameworkVersion.StartsWith(Net10, StringComparison.Ordinal) then ReplaceVariablesForLegacyFxOnWindows([@"{WindowsFramework}\v1.0.3705"])
233-
elif targetFrameworkVersion.StartsWith(Net11, StringComparison.Ordinal) then ReplaceVariablesForLegacyFxOnWindows([@"{WindowsFramework}\v1.1.4322"])
234-
elif targetFrameworkVersion.StartsWith(Net20, StringComparison.Ordinal) then ReplaceVariablesForLegacyFxOnWindows([@"{WindowsFramework}\v2.0.50727"])
235-
elif targetFrameworkVersion.StartsWith(Net30, StringComparison.Ordinal) then ReplaceVariablesForLegacyFxOnWindows([@"{ReferenceAssemblies}\v3.0"; @"{WindowsFramework}\v3.0"; @"{WindowsFramework}\v2.0.50727"])
236-
elif targetFrameworkVersion.StartsWith(Net35, StringComparison.Ordinal) then ReplaceVariablesForLegacyFxOnWindows([@"{ReferenceAssemblies}\v3.5"; @"{WindowsFramework}\v3.5"; @"{ReferenceAssemblies}\v3.0"; @"{WindowsFramework}\v3.0"; @"{WindowsFramework}\v2.0.50727"])
237-
else GetPathToDotNetFrameworkReferenceAssembliesFor40Plus(targetFrameworkVersion)
181+
let result = GetPathToDotNetFrameworkReferenceAssemblies(targetFrameworkVersion)
238182

239183
let result = result |> Array.ofList
240184
logMessage (sprintf "Derived target framework directories for version %s are: %s" targetFrameworkVersion (String.Join(",", result)))

0 commit comments

Comments
 (0)