删除未使用的源代码文件

删除未使用的源代码文件

本文介绍了删除未使用的源代码文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio 2010中,我有一个大型解决方案,其中包含许多不再使用(.csproj中未引用)但仍存在于代码存储库中的.cs文件(ClearCase).您是否知道会找到所有此类文件的任何工具/扩展名/脚本?

In Visual Studio 2010 I have a large solution that contains number of .cs files that are no longer used (not referenced in .csproj), but still present in code repository (ClearCase). Do you know of any tool / extension / script that would find all such files?

可以编写一个脚本,该脚本遍历所有项目的目录,获取所有签入的文件,然后将其与项目文件的内容进行比较.因为那里不存在,所以我们有一个删除候选对象.它不是太奇特,所以我想知道这样的脚本是否已经存在.否则,这将是清除我的Python书上尘土的好机会.

One could write a script that goes through all projects' directories, takes all files that are checked in and than compares against content of a project file. In it is not there, than we have a candidate for deletion. It is not too exotic, so I wonder whether such a script already exist. Otherwise it will be a good occasion to get dust off my Python book.

推荐答案

在SO上已经讨论过的唯一脚本是"".

The only script already discussed on SO was "Visual Studio macro: Find files that aren't included in the project?".

可以使用cleartool命令完成此操作:

It could be completed with a cleartool command in order to :

  • 签出上级目录
  • cleartool rmname -force the_file(其中强制删除)
  • 签入父目录.
  • checkout the parent directory
  • cleartool rmname -force the_file (which allows to force the delete)
  • checkin the parent directory.

由于有点麻烦,另一种方法是:

Since it is a bit cumbersome, another approach would be to:

  • 运行脚本并删除未使用的文件(简单的OS删除,与ClearCase无关)
  • 使用-rmname选项将结果导入回ClearCase(使用 clearfsimport ):删除导入源中不再存在的目标文件(即执行清洁脚本的目标文件).
  • run the script and delete the unused files (simple OS delete, nothing to do with ClearCase)
  • import the result back into ClearCase (with clearfsimport), using a -rmname option: that will automatically delete the target files which are no longer present in the imported source (ie the one where you executed your cleaning script).

这篇关于删除未使用的源代码文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 06:47