Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 757
srmark Avatar asked Dec 06 '25 06:12

srmark


1 Answers

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.)

like image 68
Jon Skeet Avatar answered Dec 08 '25 20:12

Jon Skeet