diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index 830a08bf2f4..c3f7ab6e0a2 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 cb5747f3c5d..1e36681680f 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 6fd5fc53120..fd6acf30bbb 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 4e1e34ea11c..82f9c225686 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 a0bf99f05bb..211ee752a39 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 9af1fa19c42..8b1c95f11a9 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 a4110506d8a..60ecd276a50 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 bddd70ea557..9021c1a640d 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 0ea5fab97c6..038551937a8 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 cee24364394..6bf71240043 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 5fa1678b110..1fc90c3d59c 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 6f93b850c47..dfd69a4d2d5 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 73ad77b0ee8..ee23fb78116 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 f539d85c4bc..b8ca16eba38 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 9f3993f415b..c84533dd8ad 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 157f72579be..bbd503effa4 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 2dcc65e9fb3..b653077c3d3 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}'