Skip to content

Instantly share code, notes, and snippets.

@robertpi
Created April 19, 2010 08:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertpi/370841 to your computer and use it in GitHub Desktop.
Save robertpi/370841 to your computer and use it in GitHub Desktop.
open System.IO
open System.Xml
let initDir = @"C:\Users\Workspace\Storm.Xsor-SDP-clean"
let fileSet =
Directory.GetFiles(initDir, "*.*", SearchOption.AllDirectories)
|> Seq.filter (fun path -> not (path.EndsWith(".csproj") || path.EndsWith(".sln") || path.Contains(".svn") ))
|> Seq.map (fun path -> path.Replace(initDir, ""))
|> Set.ofSeq
let filesOfCsproj (projfile: string) =
let dir = Path.GetDirectoryName(projfile);
let dom = new XmlDocument()
dom.Load(projfile)
let nsm = new XmlNamespaceManager(dom.NameTable)
nsm.AddNamespace("msb", "http://schemas.microsoft.com/developer/msbuild/2003")
let nodes = dom.SelectNodes("//@Include", nsm)
let containsIllegalChar input =
let illegalChars = seq { yield! Path.GetInvalidPathChars(); yield '*' }
input |> Seq.exists(fun x -> illegalChars |> Seq.exists(fun y -> y = x))
seq { for x in nodes do if not (containsIllegalChar x.InnerText) then
yield Path.GetFullPath( Path.Combine(dir, x.InnerText) ) }
let vsFilesSet =
Directory.GetFiles(initDir, "*.csproj", SearchOption.AllDirectories)
|> Seq.map filesOfCsproj
|> Seq.reduce Seq.append
|> Seq.map (fun path -> path.Replace(initDir, ""))
|> Set.ofSeq
printfn "fileSet.Count: %i" fileSet.Count
printfn "vsFilesSet.Count: %A" vsFilesSet.Count
let unusedFiles = fileSet - vsFilesSet
printfn "fileSet - vsFilesSet:"
unusedFiles |> Seq.iter (printfn "%s")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment