@@ -211,64 +211,63 @@ namespace rec Microsoft.VisualStudio.FSharp.ProjectSystem
211211member this.ListAvailableFSharpCoreVersions ( _ ) = Array.empty}
212212
213213let service =
214- match Internal.Utilities.FSharpEnvironment.BinFolderOfDefaultFSharpCompiler( None) with
215- | None-> nullService
216- | Some path->
217- try
218- let supportedRuntimesXml = System.Xml.Linq.XDocument.Load( Path.Combine( path, " SupportedRuntimes.xml" ))
219- let tryGetAttr ( el : System.Xml.Linq.XElement ) attr =
220- match el.Attribute( System.Xml.Linq.XName.Get attr) with
221- | null -> None
222- | x-> Some x.Value
223- let flatList =
224- supportedRuntimesXml.Root.Elements( System.Xml.Linq.XName.Get" TargetFramework" )
225- |> Seq.choose( fun tf ->
226- match tryGetAttr tf" Identifier" , tryGetAttr tf" Version" , tryGetAttr tf" Profile" with
227- | Some key1, Some key2, _
228- | Some key1, _, Some key2->
229- Some(
230- key1, // identifier
231- key2, // version or profile
232- [|
233- for asmin tf.Elements( System.Xml.Linq.XName.Get" Assembly" ) do
234- let version = asm.Attribute( System.Xml.Linq.XName.Get" Version" )
235- let description = asm.Attribute( System.Xml.Linq.XName.Get" Description" )
236- match version, descriptionwith
237- | null , _ | _, null -> ()
238- | version, description->
239- yield Microsoft.VisualStudio.FSharp.ProjectSystem.FSharpCoreVersion( version.Value, description.Value)
240- |]
241- )
242- | _ -> None
243- )
244-
245- |> Seq.toList
246- let ( _ , _ , v2 ) = flatList|> List.find( fun ( k1 , k2 , _ ) -> k1= FSharpSDKHelper.NETFramework&& k2= FSharpSDKHelper.v20)
247- let ( _ , _ , v4 ) = flatList|> List.find( fun ( k1 , k2 , _ ) -> k1= FSharpSDKHelper.NETFramework&& k2= FSharpSDKHelper.v40)
248- let ( _ , _ , v45 ) = flatList|> List.find( fun ( k1 , k2 , _ ) -> k1= FSharpSDKHelper.NETFramework&& k2= FSharpSDKHelper.v45)
249- {
250- new Microsoft.VisualStudio.FSharp.ProjectSystem.IFSharpCoreVersionLookupServicewith
251- member this.ListAvailableFSharpCoreVersions ( targetFramework ) =
252- if targetFramework.Identifier= FSharpSDKHelper.NETFramework
253- then
254- // for .NETFramework we distinguish between 2.0, 4.0 and 4.5
255- if targetFramework.Version.Major< 4 then v2
256- elif targetFramework.Version.Major= 4 && targetFramework.Version.Minor< 5 then v4
257- else v45
258- else
259- // for other target frameworks we assume that they are distinguished by the profile
260- let result =
261- flatList
262- |> List.tryPick( fun ( k1 , k2 , list ) ->
263- if k1= targetFramework.Identifier&& k2= targetFramework.Profilethen Some listelse None
264- )
265- match resultwith
266- | Some list-> list
267- | None->
268- Debug.Assert( false , sprintf" Unexpected target framework identifier '%O '" targetFramework)
269- [||]
270- }
271- with _ -> nullService
214+ try
215+ // SupportedRuntimes is deployed alongside the ProjectSystem dll
216+ let path = Path.GetDirectoryName( Assembly.GetExecutingAssembly() .Location)
217+ let supportedRuntimesXml = System.Xml.Linq.XDocument.Load( Path.Combine( path, " SupportedRuntimes.xml" ))
218+ let tryGetAttr ( el : System.Xml.Linq.XElement ) attr =
219+ match el.Attribute( System.Xml.Linq.XName.Get attr) with
220+ | null -> None
221+ | x-> Some x.Value
222+ let flatList =
223+ supportedRuntimesXml.Root.Elements( System.Xml.Linq.XName.Get" TargetFramework" )
224+ |> Seq.choose( fun tf ->
225+ match tryGetAttr tf" Identifier" , tryGetAttr tf" Version" , tryGetAttr tf" Profile" with
226+ | Some key1, Some key2, _
227+ | Some key1, _, Some key2->
228+ Some(
229+ key1, // identifier
230+ key2, // version or profile
231+ [|
232+ for asmin tf.Elements( System.Xml.Linq.XName.Get" Assembly" ) do
233+ let version = asm.Attribute( System.Xml.Linq.XName.Get" Version" )
234+ let description = asm.Attribute( System.Xml.Linq.XName.Get" Description" )
235+ match version, descriptionwith
236+ | null , _ | _, null -> ()
237+ | version, description->
238+ yield Microsoft.VisualStudio.FSharp.ProjectSystem.FSharpCoreVersion( version.Value, description.Value)
239+ |]
240+ )
241+ | _ -> None
242+ )
243+
244+ |> Seq.toList
245+ let ( _ , _ , v2 ) = flatList|> List.find( fun ( k1 , k2 , _ ) -> k1= FSharpSDKHelper.NETFramework&& k2= FSharpSDKHelper.v20)
246+ let ( _ , _ , v4 ) = flatList|> List.find( fun ( k1 , k2 , _ ) -> k1= FSharpSDKHelper.NETFramework&& k2= FSharpSDKHelper.v40)
247+ let ( _ , _ , v45 ) = flatList|> List.find( fun ( k1 , k2 , _ ) -> k1= FSharpSDKHelper.NETFramework&& k2= FSharpSDKHelper.v45)
248+ {
249+ new Microsoft.VisualStudio.FSharp.ProjectSystem.IFSharpCoreVersionLookupServicewith
250+ member this.ListAvailableFSharpCoreVersions ( targetFramework ) =
251+ if targetFramework.Identifier= FSharpSDKHelper.NETFramework
252+ then
253+ // for .NETFramework we distinguish between 2.0, 4.0 and 4.5
254+ if targetFramework.Version.Major< 4 then v2
255+ elif targetFramework.Version.Major= 4 && targetFramework.Version.Minor< 5 then v4
256+ else v45
257+ else
258+ // for other target frameworks we assume that they are distinguished by the profile
259+ let result =
260+ flatList
261+ |> List.tryPick( fun ( k1 , k2 , list ) ->
262+ if k1= targetFramework.Identifier&& k2= targetFramework.Profilethen Some listelse None
263+ )
264+ match resultwith
265+ | Some list-> list
266+ | None->
267+ Debug.Assert( false , sprintf" Unexpected target framework identifier '%O '" targetFramework)
268+ [||]
269+ }
270+ with _ -> nullService
272271( this:> IServiceContainer) .AddService( typeof< Microsoft.VisualStudio.FSharp.ProjectSystem.IFSharpCoreVersionLookupService>, service, promote= true )
273272
274273