コード例 #1
0
        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();
        }