Is it possible to view dependencies for a project in a .net core application? I'm using Visual Studio 2017 Professional
.
At the moment I have the following nugget packages referenced in my csproj
.
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.1" />
<PackageReference Include="SimpleInjector.Integration.AspNetCore.Mvc" Version="4.0.8" />
</ItemGroup>
Where you can navigate dependencies.
But it makes it hard to find a particular dependency - a tree is good if you know what you are looking for. Is there a way to output a flat list of dependant assemblies and there versions?
This flashed up today in the
Morning Brew
which might be worth a look:Martin Bjorkstrom Dotnet Depends
You can add an msbuild target to your project file (inside the
<Project>
element) like this:Which you can call like this (a line without a parent package name means it is referenced by the project directly):
If you wanted a "reverse dependency tree" - a list of packages and which packages reference them - you can do something similar to:
which produces the following output:
There isn't really documentation about these items, but they have "public" name and are generated by the ResolvePackageDependencies task which is executed as part of the RunResolvePackageDependencies target and produces a few very useful items:
TargetDefinitions
,PackageDefinitions
,PackageDependencies
,FileDependencies
andDiagnosticMessages
.