提交 42b38bf3 编写于 作者: V Vasily Kirichenko 提交者: Don Syme

Fix "The path is not of a legal form" during loading VFT solution (#3007)

* check if a referenced assembly exists before adding it into ProjectContext's metadata references

* check path correctness
上级 53f1103e
......@@ -264,6 +264,9 @@ and
project.Disconnect()
| _ -> ()
let invalidPathChars = set (Path.GetInvalidPathChars())
let isPathWellFormed (path: string) = not (String.IsNullOrWhiteSpace path) && path |> Seq.forall (fun c -> not (Set.contains c invalidPathChars))
override this.Initialize() =
base.Initialize()
......@@ -304,9 +307,11 @@ and
/// Sync the information for the project
member this.SyncProject(project: AbstractProject, projectContext: IWorkspaceProjectContext, site: IProjectSite, workspace, forceUpdate) =
let hashSetIgnoreCase x = new HashSet<string>(x, StringComparer.OrdinalIgnoreCase)
let updatedFiles = site.SourceFilesOnDisk() |> hashSetIgnoreCase
let workspaceFiles = project.GetCurrentDocuments() |> Seq.map(fun file -> file.FilePath) |> hashSetIgnoreCase
let wellFormedFilePathSetIgnoreCase (paths: seq<string>) =
HashSet(paths |> Seq.filter isPathWellFormed, StringComparer.OrdinalIgnoreCase)
let updatedFiles = site.SourceFilesOnDisk() |> wellFormedFilePathSetIgnoreCase
let workspaceFiles = project.GetCurrentDocuments() |> Seq.map (fun file -> file.FilePath) |> wellFormedFilePathSetIgnoreCase
let mutable updated = forceUpdate
......@@ -314,17 +319,19 @@ and
if not(workspaceFiles.Contains(file)) then
projectContext.AddSourceFile(file)
updated <- true
for file in workspaceFiles do
if not(updatedFiles.Contains(file)) then
projectContext.RemoveSourceFile(file)
updated <- true
let updatedRefs = site.AssemblyReferences() |> hashSetIgnoreCase
let workspaceRefs = project.GetCurrentMetadataReferences() |> Seq.map(fun ref -> ref.FilePath) |> hashSetIgnoreCase
let updatedRefs = site.AssemblyReferences() |> wellFormedFilePathSetIgnoreCase
let workspaceRefs = project.GetCurrentMetadataReferences() |> Seq.map (fun ref -> ref.FilePath) |> wellFormedFilePathSetIgnoreCase
for ref in updatedRefs do
if not(workspaceRefs.Contains(ref)) then
projectContext.AddMetadataReference(ref, MetadataReferenceProperties.Assembly)
for ref in workspaceRefs do
if not(updatedRefs.Contains(ref)) then
projectContext.RemoveMetadataReference(ref)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册