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

3

1

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

Creodont answered 18/2, 2009 at 13:27 Comment(1)
The PowerShell script in my other post will do this for you. https://mcmap.net/q/818028/-remove-unused-cs-files-in-solution.Estebanesteem
A
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.

Alake answered 18/2, 2009 at 13:35 Comment(2)
Yeah, efficient isn't an issue here for a once-every-now-and-again script. I was wondering what that script should look like though (my scripting-fu isn't much up to date than VBScript, so I might end up with a C# app...)Creodont
Will try to whip something if I can, don't count on it though. As for an optimization that crossed my mind -- you can probably use two different threads, one to identify the files, another to delete identified files.Alake
E
0

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

Excite answered 18/2, 2009 at 13:47 Comment(1)
Yeah, the whole point though really is that I want something that will do it automatically.Creodont
E
0

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://mcmap.net/q/818028/-remove-unused-cs-files-in-solution

Estebanesteem answered 2/5, 2014 at 11:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.