diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs
index 830a08bf2f41bd7e14fff08d4b85a883443651ec..c3f7ab6e0a2ac6dd601deb829648a12826aca7cc 100644
--- a/src/fsharp/CompileOps.fs
+++ b/src/fsharp/CompileOps.fs
@@ -2790,22 +2790,26 @@ type TcConfig private (data : TcConfigBuilder, validate:bool) =
error(Error(FSComp.SR.buildExplicitCoreLibRequiresNoFramework("--noframework"), rangeStartup))
let ilGlobals = mkILGlobals ILScopeRef.Local
+
+ // clrRoot: the location of the primary assembly (mscorlib.dll or netstandard.dll or System.Runtime.dll)
+ //
+ // targetFrameworkVersionValue: Normally just HighestInstalledNetFrameworkVersion()
+ //
+ // Note, when mscorlib.dll has been given explicitly the actual value of
+ // targetFrameworkVersion shouldn't matter since resolution has already happened.
+ // In those cases where it does matter (e.g. --noframework is not being used or we are processing further
+ // resolutions for a script) then it is correct to just use HighestInstalledNetFrameworkVersion().
let clrRootValue, targetFrameworkVersionValue =
match primaryAssemblyExplicitFilenameOpt with
- | Some(primaryAssemblyFilename) ->
+ | Some primaryAssemblyFilename ->
let filename = ComputeMakePathAbsolute data.implicitIncludeDir primaryAssemblyFilename
try
- use ilReader = OpenILBinary(filename, data.reduceMemoryUsage, ilGlobals, None, data.shadowCopyReferences, data.tryGetMetadataSnapshot)
- let ilModule = ilReader.ILModuleDef
- match ilModule.ManifestOfAssembly.Version with
- | Some(v1, v2, _, _) ->
- let clrRoot = Some(Path.GetDirectoryName(FileSystem.GetFullPathShim(filename)))
- clrRoot, (sprintf "v%d.%d" v1 v2)
- | _ ->
- failwith (FSComp.SR.buildCouldNotReadVersionInfoFromMscorlib())
+ let clrRoot = Some(Path.GetDirectoryName(FileSystem.GetFullPathShim(filename)))
+ clrRoot, data.legacyReferenceResolver.HighestInstalledNetFrameworkVersion()
with e ->
+ // We no longer expect the above to fail but leaving this just in case
error(Error(FSComp.SR.buildErrorOpeningBinaryFile(filename, e.Message), rangeStartup))
- | _ ->
+ | None ->
#if !ENABLE_MONO_SUPPORT
// TODO: we have to get msbuild out of this
if data.useSimpleResolution then
@@ -2821,6 +2825,7 @@ type TcConfig private (data : TcConfigBuilder, validate:bool) =
let fsharpBinariesDirValue =
// NOTE: It's not clear why this behaviour has been changed for the NETSTANDARD compilations of the F# compiler
#if NETSTANDARD1_6 || NETSTANDARD2_0
+ ignore ilGlobals
data.defaultFSharpBinariesDir
#else
match fslibExplicitFilenameOpt with
diff --git a/src/fsharp/FSComp.txt b/src/fsharp/FSComp.txt
index cb5747f3c5d4d797a7d44c1de0ed54c343f32c32..1e36681680f0c53fd609836a16eb66f889088b55 100644
--- a/src/fsharp/FSComp.txt
+++ b/src/fsharp/FSComp.txt
@@ -44,7 +44,6 @@ buildProductNameCommunity,"F# Compiler for F# %s"
213,buildInvalidAssemblyName,"'%s' is not a valid assembly name"
214,buildInvalidPrivacy,"Unrecognized privacy setting '%s' for managed resource, valid options are 'public' and 'private'"
215,buildMultipleReferencesNotAllowed,"Multiple references to '%s.dll' are not permitted"
-buildCouldNotReadVersionInfoFromMscorlib,"Could not read version from mscorlib.dll"
218,buildCannotReadAssembly,"Unable to read assembly '%s'"
220,buildAssemblyResolutionFailed,"Assembly resolution failure at or near this location"
221,buildImplicitModuleIsNotLegalIdentifier,"The declarations in this file will be placed in an implicit module '%s' based on the file name '%s'. However this is not a valid F# identifier, so the contents will not be accessible from other files. Consider renaming the file or adding a 'module' or 'namespace' declaration at the top of the file."
diff --git a/src/fsharp/SimulatedMSBuildReferenceResolver.fs b/src/fsharp/SimulatedMSBuildReferenceResolver.fs
index 6fd5fc5312096cf3b625344ad741fedf50ee35df..fd6acf30bbbc3244d2959df56a09bb523014abbb 100644
--- a/src/fsharp/SimulatedMSBuildReferenceResolver.fs
+++ b/src/fsharp/SimulatedMSBuildReferenceResolver.fs
@@ -147,13 +147,14 @@ let internal SimulatedMSBuildResolver =
match n.Version, n.GetPublicKeyToken() with
| null, _ | _,null ->
let options =
- [ for gacdir in Directory.EnumerateDirectories(gac) do
- let assdir = Path.Combine(gacdir,n.Name)
- if Directory.Exists(assdir) then
- for tdir in Directory.EnumerateDirectories(assdir) do
- let trialPath = Path.Combine(tdir,qual)
- if FileSystem.SafeExists(trialPath) then
- yield trialPath ]
+ [ if Directory.Exists(gac) then
+ for gacdir in Directory.EnumerateDirectories(gac) do
+ let assemblyDir = Path.Combine(gacdir,n.Name)
+ if Directory.Exists(assemblyDir) then
+ for tdir in Directory.EnumerateDirectories(assemblyDir) do
+ let trialPath = Path.Combine(tdir,qual)
+ if FileSystem.SafeExists(trialPath) then
+ yield trialPath ]
//printfn "sorting GAC paths: %A" options
options
|> List.sort // puts latest version last
@@ -161,21 +162,22 @@ let internal SimulatedMSBuildResolver =
|> function None -> () | Some p -> success p
| v,tok ->
- for gacdir in Directory.EnumerateDirectories(gac) do
- //printfn "searching GAC directory: %s" gacdir
- let assdir = Path.Combine(gacdir,n.Name)
- if Directory.Exists(assdir) then
- //printfn "searching GAC directory: %s" assdir
-
- let tokText = String.concat "" [| for b in tok -> sprintf "%02x" b |]
- let verdir = Path.Combine(assdir,"v4.0_"+v.ToString()+"__"+tokText)
- //printfn "searching GAC directory: %s" verdir
-
- if Directory.Exists(verdir) then
- let trialPath = Path.Combine(verdir,qual)
- //printfn "searching GAC: %s" trialPath
- if FileSystem.SafeExists(trialPath) then
- success trialPath
+ if Directory.Exists(gac) then
+ for gacdir in Directory.EnumerateDirectories(gac) do
+ //printfn "searching GAC directory: %s" gacdir
+ let assemblyDir = Path.Combine(gacdir,n.Name)
+ if Directory.Exists(assemblyDir) then
+ //printfn "searching GAC directory: %s" assemblyDir
+
+ let tokText = String.concat "" [| for b in tok -> sprintf "%02x" b |]
+ let verdir = Path.Combine(assemblyDir,"v4.0_"+v.ToString()+"__"+tokText)
+ //printfn "searching GAC directory: %s" verdir
+
+ if Directory.Exists(verdir) then
+ let trialPath = Path.Combine(verdir,qual)
+ //printfn "searching GAC: %s" trialPath
+ if FileSystem.SafeExists(trialPath) then
+ success trialPath
with e -> logWarningOrError false "SR001" (e.ToString())
#endif
diff --git a/src/fsharp/xlf/FSComp.txt.cs.xlf b/src/fsharp/xlf/FSComp.txt.cs.xlf
index 4e1e34ea11c4970ed6b0cd3f74e4d404a825e45a..82f9c2256865ac5920818ba58e76df1df9aaf100 100644
--- a/src/fsharp/xlf/FSComp.txt.cs.xlf
+++ b/src/fsharp/xlf/FSComp.txt.cs.xlf
@@ -217,11 +217,6 @@
Víc odkazů na knihovnu {0}.dll se nepovoluje.
-
- Could not read version from mscorlib.dll
- Nedala se přečíst verze souboru mscorlib.dll.
-
- Unable to read assembly '{0}'Sestavení {0} se nedá přečíst.
diff --git a/src/fsharp/xlf/FSComp.txt.de.xlf b/src/fsharp/xlf/FSComp.txt.de.xlf
index a0bf99f05bb27a6277643bbde886b319bca35ef9..211ee752a39d5cc96b904207ee67addea859414b 100644
--- a/src/fsharp/xlf/FSComp.txt.de.xlf
+++ b/src/fsharp/xlf/FSComp.txt.de.xlf
@@ -217,11 +217,6 @@
Mehrere Verweise auf "{0}.dll" sind nicht zulässig
-
- Could not read version from mscorlib.dll
- Version konnte nicht aus "mscorlib.dll" gelesen werden.
-
- Unable to read assembly '{0}'Assembly "{0}" kann nicht gelesen werden.
diff --git a/src/fsharp/xlf/FSComp.txt.en.xlf b/src/fsharp/xlf/FSComp.txt.en.xlf
index 9af1fa19c42bdcedb47180fd904087f07729b7cd..8b1c95f11a9ed653c6aa1f4bfb25f88918426c43 100644
--- a/src/fsharp/xlf/FSComp.txt.en.xlf
+++ b/src/fsharp/xlf/FSComp.txt.en.xlf
@@ -217,11 +217,6 @@
Multiple references to '{0}.dll' are not permitted
-
- Could not read version from mscorlib.dll
- Could not read version from mscorlib.dll
-
- Unable to read assembly '{0}'Unable to read assembly '{0}'
diff --git a/src/fsharp/xlf/FSComp.txt.es.xlf b/src/fsharp/xlf/FSComp.txt.es.xlf
index a4110506d8a7bb12aad86dedb2ee873f4b4174f0..60ecd276a502293100bb07081076ea10da5f9496 100644
--- a/src/fsharp/xlf/FSComp.txt.es.xlf
+++ b/src/fsharp/xlf/FSComp.txt.es.xlf
@@ -217,11 +217,6 @@
No se permiten varias referencias a '{0}.dll'.
-
- Could not read version from mscorlib.dll
- No se pudo leer la versión de mscorlib.dll.
-
- Unable to read assembly '{0}'No se puede leer el ensamblado '{0}'.
diff --git a/src/fsharp/xlf/FSComp.txt.fr.xlf b/src/fsharp/xlf/FSComp.txt.fr.xlf
index bddd70ea5570806fed0fdc34fa3dc5393d7760bd..9021c1a640d8c5e072c98739c6165a44a2858279 100644
--- a/src/fsharp/xlf/FSComp.txt.fr.xlf
+++ b/src/fsharp/xlf/FSComp.txt.fr.xlf
@@ -217,11 +217,6 @@
Les références multiples à '{0}.dll' ne sont pas autorisées
-
- Could not read version from mscorlib.dll
- Impossible de lire la version à partir de mscorlib.dll
-
- Unable to read assembly '{0}'Impossible de lire l'assembly '{0}'
diff --git a/src/fsharp/xlf/FSComp.txt.it.xlf b/src/fsharp/xlf/FSComp.txt.it.xlf
index 0ea5fab97c60874b2af16600a51086e72070ccb0..038551937a8fd8a798e0b16ad6e65ae5f50a2422 100644
--- a/src/fsharp/xlf/FSComp.txt.it.xlf
+++ b/src/fsharp/xlf/FSComp.txt.it.xlf
@@ -217,11 +217,6 @@
Non sono consentiti più riferimenti a '{0}.dll'
-
- Could not read version from mscorlib.dll
- Non è stato possibile leggere la versione da mscorlib.dll
-
- Unable to read assembly '{0}'Non è possibile leggere l'assembly '{0}'
diff --git a/src/fsharp/xlf/FSComp.txt.ja.xlf b/src/fsharp/xlf/FSComp.txt.ja.xlf
index cee24364394230778e16a35e0e29485acd8c0444..6bf7124004393715f7f033c23cc57b5c9db8ee40 100644
--- a/src/fsharp/xlf/FSComp.txt.ja.xlf
+++ b/src/fsharp/xlf/FSComp.txt.ja.xlf
@@ -217,11 +217,6 @@
'{0}.dll' に対する複数の参照は許可されていません
-
- Could not read version from mscorlib.dll
- mscorlib.dll からバージョンを読み取ることができませんでした
-
- Unable to read assembly '{0}'アセンブリ '{0}' を読み取れません
diff --git a/src/fsharp/xlf/FSComp.txt.ko.xlf b/src/fsharp/xlf/FSComp.txt.ko.xlf
index 5fa1678b1102f7cf25b177c455f1bd42944b4f0e..1fc90c3d59c41ce2fbfa90478509998a13517e4d 100644
--- a/src/fsharp/xlf/FSComp.txt.ko.xlf
+++ b/src/fsharp/xlf/FSComp.txt.ko.xlf
@@ -217,11 +217,6 @@
'{0}.dll'에 대한 다중 참조는 허용되지 않습니다.
-
- Could not read version from mscorlib.dll
- mscorlib.dll에서 버전을 읽을 수 없습니다.
-
- Unable to read assembly '{0}''{0}' 어셈블리를 읽을 수 없습니다.
diff --git a/src/fsharp/xlf/FSComp.txt.pl.xlf b/src/fsharp/xlf/FSComp.txt.pl.xlf
index 6f93b850c474ab2bfff56580cac140e34ef549c1..dfd69a4d2d5a0c1e8df03c6cb749e535848c3eed 100644
--- a/src/fsharp/xlf/FSComp.txt.pl.xlf
+++ b/src/fsharp/xlf/FSComp.txt.pl.xlf
@@ -217,11 +217,6 @@
Używanie wielu odwołań do pliku „{0}.dll” jest niedozwolone
-
- Could not read version from mscorlib.dll
- Nie można odczytać wersji z pliku mscorlib.dll
-
- Unable to read assembly '{0}'Nie można odczytać zestawu „{0}”
diff --git a/src/fsharp/xlf/FSComp.txt.pt-BR.xlf b/src/fsharp/xlf/FSComp.txt.pt-BR.xlf
index 73ad77b0ee8d539151645a780a7dede6236ffd59..ee23fb78116568635f1fe5fa59fc2b6deda13a6a 100644
--- a/src/fsharp/xlf/FSComp.txt.pt-BR.xlf
+++ b/src/fsharp/xlf/FSComp.txt.pt-BR.xlf
@@ -217,11 +217,6 @@
As referências múltiplas '{0}.dll' não são permitidas
-
- Could not read version from mscorlib.dll
- Não foi possível ler a versão em mscorlib.dll
-
- Unable to read assembly '{0}'Não é possível ler o assembly '{0}'
diff --git a/src/fsharp/xlf/FSComp.txt.ru.xlf b/src/fsharp/xlf/FSComp.txt.ru.xlf
index f539d85c4bcd1e6ec9257b37b7fd513222aa3711..b8ca16eba388e5ed268179a9965f1b2880c3b2f4 100644
--- a/src/fsharp/xlf/FSComp.txt.ru.xlf
+++ b/src/fsharp/xlf/FSComp.txt.ru.xlf
@@ -217,11 +217,6 @@
Множественные ссылки на файлы "{0}.dll" не допускаются
-
- Could not read version from mscorlib.dll
- Не удалось прочитать версию из библиотеки mscorlib.dll
-
- Unable to read assembly '{0}'Не удается прочитать сборку "{0}"
diff --git a/src/fsharp/xlf/FSComp.txt.tr.xlf b/src/fsharp/xlf/FSComp.txt.tr.xlf
index 9f3993f415bcdab4020cc7fc2498b4f497a8595a..c84533dd8adfab7e1e723c70eafd3cabeb986301 100644
--- a/src/fsharp/xlf/FSComp.txt.tr.xlf
+++ b/src/fsharp/xlf/FSComp.txt.tr.xlf
@@ -217,11 +217,6 @@
Birden çok '{0}.dll' başvurusuna izin verilmiyor
-
- Could not read version from mscorlib.dll
- Sürüm, mscorlib.dll'den okunamadı
-
- Unable to read assembly '{0}''{0}' bütünleştirilmiş kodu okunamıyor
diff --git a/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf b/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf
index 157f72579be26acb012dda3d2b7265a4b984fa21..bbd503effa47177e11761c79a915c8e34a2b3738 100644
--- a/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf
+++ b/src/fsharp/xlf/FSComp.txt.zh-Hans.xlf
@@ -217,11 +217,6 @@
不允许多次引用“{0}.dll”
-
- Could not read version from mscorlib.dll
- 未能从 mscorlib.dll 读取版本
-
- Unable to read assembly '{0}'无法读取程序集“{0}”
diff --git a/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf b/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf
index 2dcc65e9fb3c337f9ee9ff601d8d14e32d70f2e5..b653077c3d399a99a152c93e05d67e0dca01e77f 100644
--- a/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf
+++ b/src/fsharp/xlf/FSComp.txt.zh-Hant.xlf
@@ -217,11 +217,6 @@
不允許多次參考 '{0}.dll'
-
- Could not read version from mscorlib.dll
- 無法從 mscorlib.dll 讀取版本
-
- Unable to read assembly '{0}'無法讀取組件 '{0}'