public void AddLibraryToInventory(Library library, bool isManifest, Inventory inv) { if (isManifest) { // only add manifests if we don't have the project loaded if (m_guidToObjectHash.ContainsKey(library.Guid.ToLower())) { return; } } string path = MsBuildWrapper.ExpandEnvVars(library.ProjectPath, "").ToLower(); if (m_projToObjectHash.ContainsKey(path)) { return; //Console.WriteLine("Warning: project path alread in inventory: " + library.ProjectPath); } m_projToObjectHash[path] = library; string libFile = Path.GetFileNameWithoutExtension(library.LibraryFile); if (!string.IsNullOrEmpty(libFile)) { libFile = libFile.ToLower(); if (m_fileToObjectHash.ContainsKey(libFile)) { if (!isManifest) { m_fileToObjectHash[libFile] = library; } } else { m_fileToObjectHash[libFile] = library; } } string guid = library.Guid; if (string.IsNullOrEmpty(guid)) { if (!isManifest) { Console.WriteLine("WARNING: project without guid found: " + library.ProjectPath); } library.Guid = Guid.NewGuid().ToString("B"); guid = library.Guid; } guid = guid.ToLower(); if (m_guidToObjectHash.ContainsKey(guid)) { Console.WriteLine("Warning: GUID alread in inventory: " + guid); } m_guidToObjectHash[guid] = library; inv.Libraries.Add(library); }
private object FindObjectByProject(string file, IList list) { string key = MsBuildWrapper.ExpandEnvVars(file, "").ToLower(); if (m_projToObjectHash.ContainsKey(key)) { object o = m_projToObjectHash[key]; if (!list.Contains(o)) { Console.WriteLine("Warning the list did not contain the project: " + file); } return(o); } if (!(list is IList <Library>)) { foreach (object o in list) { try { string g = o.GetType().GetProperty("ProjectPath").GetValue(o, null) as string; g = MsBuildWrapper.ExpandEnvVars(g, "").ToLower(); if (0 == string.Compare(g, key, true)) { m_projToObjectHash[g] = o; return(o); } } catch { } } } return(null); }