public void RemoveReference(VSProjectItem p) { if (p.ItemType != "Reference") { return; } Microsoft.Build.Evaluation.Project pc = new Microsoft.Build.Evaluation.Project(FileName); if (pc == null) { return; } ICollection <Microsoft.Build.Evaluation.ProjectItem> c = pc.GetItemsByEvaluatedInclude(p.Include); foreach (Microsoft.Build.Evaluation.ProjectItem pp in c) { if (pp.ItemType == "Reference") { pc.RemoveItem(pp); } } pc.Save(FileName); pc.ProjectCollection.UnloadAllProjects(); }
public void CreateFolder(string folder, VSProjectItem ps) { Microsoft.Build.Evaluation.Project pc = new Microsoft.Build.Evaluation.Project(FileName); if (pc == null) { return; } string s = Path.GetDirectoryName(FileName); ArrayList R = GetItems(pc, "Folder", false); if (ps == null || ps.ItemType != "Folder") { string refs = GetRelativePath(s, folder); int i = R.IndexOf(refs); if (i < 0) { pc.AddItem("Folder", refs); } } else { string g = ps.Include; g = g + "\\" + folder; string refs = GetRelativePath(s, g); int i = R.IndexOf(refs); if (i < 0) { pc.AddItem("Folder", refs); } } pc.Save(FileName); pc.ProjectCollection.UnloadAllProjects(); }