Skip to content

Commit 923f42c

Browse files
KevinRansombrettfo
authored andcommitted
Dev15.6 -- Fix multi-targetting / F# IDE (dotnet#4286)
* Fix multi-targetting * Refactor * address project relative paths
1 parent 7c07673 commit 923f42c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

vsintegration/src/FSharp.Editor/LanguageService/LanguageService.fs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,21 @@ type internal FSharpProjectOptionsManager
226226

227227
[<Export>]
228228
/// This handles commandline change notifications from the Dotnet Project-system
229+
/// Prior to VS 15.7 path contained path to project file, post 15.7 contains target binpath
230+
/// binpath is more accurate because a project file can have multiple in memory projects based on configuration
229231
member this.HandleCommandLineChanges(path:string, sources:ImmutableArray<CommandLineSourceFile>, references:ImmutableArray<CommandLineReference>, options:ImmutableArray<string>) =
232+
let projectId =
233+
match workspace.ProjectTracker.TryGetProjectByBinPath(path) with
234+
| true, project -> project.Id
235+
| false, _ -> workspace.ProjectTracker.GetOrCreateProjectIdForPath(path, projectDisplayNameOf path)
236+
let project = workspace.ProjectTracker.GetProject(projectId)
237+
let path = project.ProjectFilePath
230238
let fullPath p =
231-
if Path.IsPathRooted(p) then p
239+
if Path.IsPathRooted(p) || path = null then p
232240
else Path.Combine(Path.GetDirectoryName(path), p)
233241
let sourcePaths = sources |> Seq.map(fun s -> fullPath s.Path) |> Seq.toArray
234242
let referencePaths = references |> Seq.map(fun r -> fullPath r.Reference) |> Seq.toArray
235-
let projectId = workspace.ProjectTracker.GetOrCreateProjectIdForPath(path, projectDisplayNameOf path)
243+
236244
projectOptionsTable.SetOptionsWithProjectId(projectId, sourcePaths, referencePaths, options.ToArray())
237245
this.UpdateProjectInfoWithProjectId(projectId, "HandleCommandLineChanges", invalidateConfig=true)
238246

0 commit comments

Comments
 (0)