How do I remove unnecessary resources from my project?

前端 未结 10 1633
深忆病人
深忆病人 2021-02-12 22:55

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

It is written in C++/C# with Visual Studio 2005.

相关标签:
10条回答
  • 2021-02-12 23:08

    For C++ resources, did you try right-clicking the project in "Resource View" and then deleting the ones which do not have a tick mark next to them? It is unsafe to delete unused dialog resources since they are referenced as "enum"s in code (like the following).

    enum { IDD = IDD_ABOUTBOX };
    

    ..however for all the others it should be safe.

    0 讨论(0)
  • 2021-02-12 23:12

    If your code contains dynamic loading of resources (e.g. via strings) at runtime, then there is no way to automatically determine which resources can be safely removed from the source. A dynamic loading statement could load any resource.

    Your best bet is to start with your trimmed down version of the app, run it, and identify which resources are missing when you test it. Then add them back in and retest.

    0 讨论(0)
  • 2021-02-12 23:25

    In the Solution Explorer, right click and on a Reference and click on the menu item Find Dependent Code.

    If it can't find any dependent code then you can remove this reference from the project. (The Remove operation is also under the right-click menu.)

    EDIT: For a large project, the Find Dependent Code operation will take a long time. So since you have 2000 resources and most likely value your time this probably is not a viable option....

    0 讨论(0)
  • 2021-02-12 23:28

    You can use third party plug-in for Visual Studio as ReSharper. This add-in will analyze your C# code and point out unused resources. But it only works with C#.

    0 讨论(0)
提交回复
热议问题