Created
September 18, 2014 11:22
-
-
Save herskinduk/4528231150d13439e325 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
<#@ template hostspecific="true" language="C#" #> | |
<#@ output extension=".txt" #> | |
<#@ assembly name="System.Core" #> | |
<#@ assembly name="VSLangProj" #> | |
<#@ import namespace="System" #> | |
<#@ import namespace="System.Reflection" #> | |
<#@ import namespace="System.Linq" #> | |
<#@ import namespace="System.Text" #> | |
<#@ import namespace="System.Collections.Generic" #> | |
<#@ assembly name="EnvDTE" #> | |
<#@ import namespace="EnvDTE" #> | |
<# | |
IServiceProvider serviceProvider = (IServiceProvider)this.Host; | |
DTE dte = serviceProvider.GetService(typeof(DTE)) as DTE; | |
foreach(Project project in dte.Solution.Projects) | |
{ | |
WriteLine(project.Name); | |
foreach(VSLangProj.Reference reference in CollectReferences(project)) | |
{ | |
WriteLine("+ " + reference.Name); | |
} | |
} | |
#> | |
<#+ | |
public static IEnumerable<VSLangProj.Reference> CollectReferences(EnvDTE.Project project) | |
{ | |
var vsproject = project.Object as VSLangProj.VSProject; | |
if (vsproject != null) | |
{ | |
foreach (VSLangProj.Reference reference in vsproject.References) | |
{ | |
if (reference.SourceProject == null) | |
{ | |
yield return reference; | |
} | |
else | |
{ | |
// This is a project reference | |
} | |
} | |
} | |
} | |
#> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment