diff --git a/src/fsharp/vs/service.fs b/src/fsharp/vs/service.fs index 1e06270838..9b2dd7ea42 100755 --- a/src/fsharp/vs/service.fs +++ b/src/fsharp/vs/service.fs @@ -2762,6 +2762,9 @@ type FSharpProjectFileInfo (fsprojFileName:string, ?properties, ?enableLogging) yield i.FinalItemSpec for i in project.GetEvaluatedItemsByName("ChildProjectReferences") do yield i.FinalItemSpec ] + // Duplicate slashes sometimes appear in the output here, which prevents + // them from matching keys used in FSharpProjectOptions.ReferencedProjects + |> List.map (fun (s: string) -> s.Replace("//","/")) outFileOpt, directory, getItems, references, projectReferences, getProp project, project.FullFileName @@ -3155,19 +3158,19 @@ type FSharpChecker(projectCacheSize, keepAssemblyContents, keepAllBackgroundReso #if SILVERLIGHT #else #if FX_ATLEAST_45 - member ic.GetProjectOptionsFromProjectFile(projectFileName, ?properties : (string * string) list, ?loadedTimeStamp) = - let parsedProject = FSharpProjectFileInfo(projectFileName, ?properties=properties) - let args = parsedProject.Options |> Array.ofList - - let projectOptions = ic.GetProjectOptionsFromCommandLineArgs(projectFileName, args, ?loadedTimeStamp=loadedTimeStamp) - let referencedProjectOptions = - [| for file in parsedProject.ProjectReferences do - if Path.GetExtension(file) = ".fsproj" then - yield file, ic.GetProjectOptionsFromProjectFile(file, ?properties=properties, ?loadedTimeStamp=loadedTimeStamp) |] - - { projectOptions - with ReferencedProjects = referencedProjectOptions } - + member ic.GetProjectOptionsFromProjectFile(projectFileName, ?properties : (string * string) list, ?loadedTimeStamp) = + let rec getOptions file : Option * FSharpProjectOptions = + let parsedProject = FSharpProjectFileInfo.Parse(file, ?properties=properties) + let projectOptions = ic.GetProjectOptionsFromCommandLineArgs(file, Array.ofList parsedProject.Options, ?loadedTimeStamp=loadedTimeStamp) + let referencedProjectOptions = + [| for file in parsedProject.ProjectReferences do + if Path.GetExtension(file) = ".fsproj" then + match getOptions file with + | Some outFile, opts -> yield outFile, opts + | None, _ -> () |] + parsedProject.OutputFile, { projectOptions with ReferencedProjects = referencedProjectOptions } + + snd (getOptions projectFileName) #endif #endif diff --git a/tests/service/ProjectOptionsTests.fs b/tests/service/ProjectOptionsTests.fs index ba863292be..d00e41cace 100644 --- a/tests/service/ProjectOptionsTests.fs +++ b/tests/service/ProjectOptionsTests.fs @@ -207,7 +207,7 @@ let ``Project file parsing -- project references``() = let options = checker.GetProjectOptionsFromProjectFile(f2) options.ReferencedProjects |> should haveLength 1 - fst options.ReferencedProjects.[0] |> should endWith "Test1.fsproj" + fst options.ReferencedProjects.[0] |> should endWith "Test1.dll" snd options.ReferencedProjects.[0] |> should equal (checker.GetProjectOptionsFromProjectFile(f1)) [] @@ -217,7 +217,7 @@ let ``Project file parsing -- multi language project``() = let options = checker.GetProjectOptionsFromProjectFile(f) options.ReferencedProjects |> should haveLength 1 - options.ReferencedProjects.[0] |> fst |> should endWith "ConsoleApplication2.fsproj" + options.ReferencedProjects.[0] |> fst |> should endWith "ConsoleApplication2.exe" checkOption options.OtherOptions "ConsoleApplication2.exe" checkOption options.OtherOptions "ConsoleApplication3.exe"