Delete files from disk that aren't in a Visual Studio project

寵の児 提交于 2019-12-08 04:42:48

问题


Can anyone think of a way (perhaps using a PowerShell script or similar) where I can look for *.cs files that are on disk in the folder structure, but aren't included in a project file?

This has come about gradually over time with merging in Subversion etc. I'm looking for a way to clean up after myself, basically. :)


回答1:


All your .cs files will be mentioned in the project file, right? Scrape the XML, list the files and then do a search on the whole system. Works, but is inefficient.




回答2:


"Show all files" button at the top of Solution Explorer, then manually inspect?




回答3:


The PowerShell script in my other post will do this. 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 pend them as deletes in TFS.

The script is here: https://stackoverflow.com/a/23420956/846428



来源:https://stackoverflow.com/questions/561043/delete-files-from-disk-that-arent-in-a-visual-studio-project

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