如何从我的项目中删除不必要的资源? [英] How do I remove unnecessary resources from my project?

查看:135
本文介绍了如何从我的项目中删除不必要的资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常大的项目工作(包含16个项目的解决方案,每个项目包含约100文件)。

I am working with a very big project (a solution that contains 16 projects and each project contains about 100 files).

这是写在C ++ / C#与Visual Studio 2005

其中一个项目有大约2000资源,走出只有400实际上是用了。

如何删除这些未使用的资源?

It is written in C++/C# with Visual Studio 2005.
One of the projects has around 2000 resources out of which only 400 are actually used.
How do I remove those unused resources?

我试图寻找用过的完成任务。

它的工作,我能构建解决方案,但它在运行时打破了。

I tried to accomplish the task by searching for used ones.
It worked and I was able to build the solution, but it broke at runtime.

我猜是因为枚举*的 s的使用。 (的*重要

I guess because enum*s are used. (*IMPORTANT)

我怎样才能确保它在运行时不破?

编辑:

我想到一个方法可以生成资源(即在运行时(在某种程度上)飞未找到)。

但是,我不知道... 什么

想法的注:这没关系,如果一个一些不必要的资源仍然存在。

推荐答案

我会做的是写一个自定义工具搜索你的源代码

What I would do is write a custom tool to search your source code.

如果你从一个头文件中删除资源ID(即所谓的可能RESOURCE.H),然后重新编译,并得到任何警告:那么这是一个很好的的事情。

If you remove a resource ID from a header file (i.e. possibly called resource.h) and then recompile and get no warnings: then that's a good thing.

下面是我会怎么去写的应用程序。作为输入你要审议的资源文件(resource.h中)。打开头文件(* .h)中并解析所有的资源的常量(或者至少你感兴趣的onces)。这些存放在哈希表中,以便快速查找更高版本。
。对于项目中的每个代码文件,搜索每个资源ID的的实例的文本。当使用资源ID,递增散列表的值,否则把它为零。
最后,转储所有资源的ID是零了一个日志文件或东西。然后测试确实可以安全地删除这些指定的资源的ID。一旦你这样做,然后写另一个工具,可以删除指定资源的ID给您的日志文件的结果。

Here is how I would go about writing the app. Take as input the resource file (resource.h) you want to scrutinize. Open the header file (*.h) and parse all the resource constants (Or at least the onces you are interested in). Store those in a hash table for quick look up later. For each code file in your project, search the text for instances of each of your resource ID's. When a resource ID is used, increment the value in the hash table otherwise leave it at zero. At the end, dump all the resource ID's that are zero out a log file or something. Then test that indeed you can remove those specified resource ID's safely. Once you do that, then write another tool that removes the specified resource ID's given the results of your log file.

您可以写在Perl这样的工具,它会执行在0.3秒左右:但是需要数天调试。 :)
或者你可以在.NET中写这篇文章,它会执行慢一点,但会带你一个小时的调试。 :)

You could write such a tool in perl and it would execute in about 0.3 seconds: But would take days to debug. :) Or you could write this in .NET, and it would execute a little slower, but would take you an hour to debug. :)

这篇关于如何从我的项目中删除不必要的资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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