Remove unused source code files

你。 提交于 2019-12-18 05:18:13

问题


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?

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.


回答1:


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

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

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

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



回答2:


The PowerShell script in my other post will get you 95% of the way. It is geared around TFS but it should be easy to modify for your purposes. The script will get the list of included files from the project file and compare that against the files on disk. You will get the set of files that are on disk but not included in the project. You can either delete them or run some other command against that set of files.

https://stackoverflow.com/a/23420956/846428



来源:https://stackoverflow.com/questions/12155522/remove-unused-source-code-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!