Skip to content

Instantly share code, notes, and snippets.

@jimmymain
Last active August 29, 2015 14:06
Show Gist options
  • Save jimmymain/d5d68ec7141a7c5f4fb0 to your computer and use it in GitHub Desktop.
Save jimmymain/d5d68ec7141a7c5f4fb0 to your computer and use it in GitHub Desktop.
references
var name = "itextsharp";
var dir = @"D:\Projects\Online\Service\Enhancements\Release\";
var recurse = true;
var ns = new XmlNamespaceManager(new NameTable());
ns.AddNamespace("x", "http://schemas.microsoft.com/developer/msbuild/2003");
foreach (var file in Directory.EnumerateFiles(dir, "*.csproj", recurse ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly))
{
var document = XDocument.Load(file);
foreach (var element in document.XPathSelectElements("/x:Project/x:ItemGroup/x:Reference[starts-with(@Include,'" + name + "')]", ns))
{
var assemblyName = new AssemblyName(element.Attribute("Include").Value);
if (assemblyName.Name == name)
string.Format("{0}: {1}", file.Replace(dir, ".."), element.Attribute("Include").Value).Dump();
}
}
var name = "autofac";
var dir = @"D:\Projects\Online\Service\Enhancements\Release\";
var ns = new XmlNamespaceManager(new NameTable());
ns.AddNamespace("x", "http://schemas.microsoft.com/developer/msbuild/2003");
foreach (var file in Directory.EnumerateFiles(dir, "packages.config", SearchOption.AllDirectories)) {
if (File.ReadAllText(file).ToLowerInvariant().Contains(name.ToLowerInvariant())) {
file.Dump();
File.ReadAllLines(file).Where(_ => _.ToLowerInvariant().Contains(name.ToLowerInvariant())).ToArray().Dump();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment