In Visual Studio, what's a quick way to delete all the exclude files from a project?

若如初见. 提交于 2019-12-23 22:18:06

问题


I have a LARGE project in visual studio 2008. It has an accumulation of a few years of trying things out and often excluding (not deleting) files from the project. I need a way to permanently delete any excluded file. There are thousands of files and hundreds of folders. Doing it manually in solution explorer would take too much time.

I could build a project file parser and compare with filesystem but I'm hoping for a shortcut.

Thanks


回答1:


Are the excluded files under source control along with the rest? If not, just make sure everything is checked in, fetch to a new temporary location, move the old directory out of the way as a backup, and move the temporary folder to where the old one was.

If the experiments are checked into source control it's slightly harder - you'll probably need to go with the project file parser. That may well not be very hard though.

EDIT: Okay, if it's all in SVN, I suggest you write a very crude project parser. Give it a list of XPath expressions (or something similar) to select as "probably paths". Select everything in the project file, and copy each file selected into a fresh location (including subdirectories etc). Also copy project files and solution files. Then try to build - if it fails, you've missed something: repeat.

Keep going until it builds, then test it. So long as everything is okay, you can then blow everything else away :)

EDIT: Here's the start of the kind of thing I mean:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;

public class ProjectParser
{
    static void Main(string[] args)
    {
        XDocument doc = XDocument.Load(args[0]);

        XNamespace ns = "http://schemas.microsoft.com/developer/msbuild/2003";
        DumpMatches(doc.Descendants(ns + "Compile")
                       .Select(x => x.Attribute("Include").Value));
        DumpMatches(doc.Descendants(ns + "AssemblyOriginatorKeyFile")
                       .Select(x => x.Value));
    }

    static void DumpMatches(IEnumerable<string> values)
    {
        foreach (string x in values)
        {
            Console.WriteLine(x);
        }
    }
}

(I originally tried with XPath, but the namespace stuff made it a pain.)




回答2:


Bring up a command prompt and try DEL/S *.exclude. I don't think you'd do much better writing an add-in to Visual Studio.



来源:https://stackoverflow.com/questions/707113/in-visual-studio-whats-a-quick-way-to-delete-all-the-exclude-files-from-a-proj

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!