Created
April 19, 2010 08:20
-
-
Save robertpi/370841 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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