Ejemplo n.º 1
0
        public void RemoveDocument(string filePath)
        {
            var relativePath = PathUtilities.GetRelativePath(_loadedProject.DirectoryPath, filePath);

            var items = _loadedProject.GetItems(ItemNames.Compile);
            var item  = items.FirstOrDefault(it => PathUtilities.PathsEqual(it.EvaluatedInclude, relativePath) ||
                                             PathUtilities.PathsEqual(it.EvaluatedInclude, filePath));

            if (item != null)
            {
                _loadedProject.RemoveItem(item);
            }
        }
Ejemplo n.º 2
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();
        }
        private static void RemoveProjectJsonReference(Microsoft.Build.Evaluation.Project buildProject, string projectJsonFilePath)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            var projectJsonItem = buildProject.GetItems("None")
                                  .Where(t => string.Equals(t.EvaluatedInclude, Path.GetFileName(projectJsonFilePath), StringComparison.OrdinalIgnoreCase))
                                  .FirstOrDefault();

            if (projectJsonItem != null)
            {
                buildProject.RemoveItem(projectJsonItem);
            }
        }