在Visual Studio中,从项目中删除所有排除文件的快速方法是什么? [英] In Visual Studio, what's a quick way to delete all the exclude files from a project?

查看:156
本文介绍了在Visual Studio中,从项目中删除所有排除文件的快速方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio 2008中有一个大型项目.它积累了数年的尝试经验,并经常从该项目中排除(而不是删除)文件.我需要一种永久删除任何排除文件的方法.有数千个文件和数百个文件夹.在解决方案资源管理器中手动执行此操作会花费太多时间.

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.

谢谢

推荐答案

被排除的文件是否与其他文件一起受到源代码控制?如果没有,只需确保一切都已签入,获取到新的临时位置,将旧目录作为备份移开,然后将临时文件夹移至旧目录所在的位置.

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.

好的,如果全部在SVN中,建议您编写一个非常原始项目解析器.给它一个XPath表达式(或类似的东西)的列表,以选择作为可能的路径".选择项目文件中的所有内容,然后将每个选择的文件复制到新位置(包括子目录等).还复制项目文件和解决方案文件.然后尝试构建-如果失败,则您错过了一些东西:重复.

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

这是我指的那种开始:

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);
        }
    }
}

(我最初尝试使用XPath,但是名称空间的东西使它很痛苦.)

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

这篇关于在Visual Studio中,从项目中删除所有排除文件的快速方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆