Git Product home page Git Product logo

solutiondependencyanalyzer's Introduction

SolutionDependencyAnalyzer

There are two ways to use the tool: Command line or use the NuGet package in your project.

Command Line

Installation

dotnet tool install --global dependency-analyzer

Usage

dependency-analyzer <SolutionFullPath> <OutputPath>
Options
  • -g or --create-graph-image : runs dot at the end of the process to create a png image of the dot graph generated. This option has a prerequisite: dot must be installed and in the PATH. To do so, you can run this command for Chocolatey: choco install graphviz or get dot there.

Files Created

This tool will create five files in the provided OutputPath:

  • packages.md contains the list of NuGet packages used by the projects in the solution, with their version.
  • packagesByProject.md will list the NuGet packages used by each project in the solution, with their version.
  • projectsByPackage.md does the opposite: it will list the projects that use each package
  • projectDependencyGraph.dot is the dependency graph of the projects in the solution. SolutionDependencyAnalyzer also generates a png of that graph, projectDependencyGraph.png

Nuget Dependency

Installation

Add the dependency-analyzer NuGet package to your project

Usage

Create a DependencyAnalyzer and call it, with Solution containing the full solution path:

var dependencyAnalyzer = new DependencyAnalyzer(Solution);
await dependencyAnalyzer.AnalyzeAsync();

Now dependencyAnalyzer properties contain everything you need:

  • PackageResults contains the package ID as key, and its version as value
  • ProjectResults is a dictionary in which the key is a project, and the values are its project dependencies
  • PackagesByProject is a dictionary in which the key is a project, and the values are its package dependencies
  • ProjectsByPackage is a dictionary in which the key is a package, and the values are its project dependencies

You can also call the writers (MarkdownWriter and DotWriter) if you want to write the same fils as the comand line tool does.

Thanks

This project was heavily inspired by dotnet-depends, and like dotnet-depends, it uses the amazing Buildalyzer

solutiondependencyanalyzer's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar tradioyes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

solutiondependencyanalyzer's Issues

Win32Exception

Every execution throws an Win32Exception around constructing the dot graph. I've tried it on several solutions.

Unhandled exception. System.ComponentModel.Win32Exception (2): An error occurred trying to start process 'dot' with working directory 'C:\dev\dflex-pbs'. The system cannot find the file specified.
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at SolutionDependencyAnalyzer.DotWriter.WriteProjectDependencyGraph(IDictionary`2 projectDependencies, String graphTitle, Boolean createImage) in D:\TravailGit\SolutionDependencyAnalyzer\SolutionDependencyAnalyzer\DotWriter.cs:line 58
   at SolutionDependencyAnalyzer.Program.OnExecuteAsync() in D:\TravailGit\SolutionDependencyAnalyzer\SolutionDependencyAnalyzer\Program.cs:line 57
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.InvokeAsync(MethodInfo method, Object instance, Object[] arguments)
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.OnExecute(ConventionContext context, CancellationToken cancellationToken)
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.<>c__DisplayClass0_0.<<Apply>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync[TApp](CommandLineContext context, CancellationToken cancellationToken)
   at SolutionDependencyAnalyzer.Program.<Main>(String[] args)

These files are created before the exception terminates the program:
projectsByPackage.md
packages.md
packagesByProject.md
projectDependencyGraph.dot

dotnet --info

.NET SDK:
 Version:   7.0.101
 Commit:    bb24aafa11

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.101\

Host:
  Version:      7.0.1
  Architecture: x64
  Commit:       97203d38ba

.NET SDKs installed:
  6.0.307 [C:\Program Files\dotnet\sdk]
  6.0.400 [C:\Program Files\dotnet\sdk]
  7.0.101 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]

Environment variables:
  Not set

global.json file:
  Not found

Find dependencies from Nuspec files

This tool only seems to list the direct dependencies of a project, but i would expect any dependency tree visualization tool to list all dependencies recursively.

Include indirect dependencies

This project looks interesting but from what I see after test run it includes only direct dependencies. I.e. let's say I have project P which has nuget N installed, but this package requires package R, I will see in the output only P->N dependency, R is off the radar.

It would be great if user would have an option, either use only direct dependencies (like today) or get full list of dependencies:

### P
  - N
     * R

so each level would be intended.

ReadKey at the end means this can't be put in an automated build script

The end of the program there is a Console.ReadKey() which causes the application to wait until a key is read from the keyboard. This means that this cannot be added to an automated build script that automatically keeps the documentation up-to-date.

Also, from VS2019 (v16.2), this type of thing is no longer necessary as VS does this for you in console apps by default (unless you turn if off).

C:\Program Files\dotnet\dotnet.exe (process 37856) exited with code 0.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .

Running Dependency Analyser without the output path results in an exception

If you run the command and accidentally miss out the output path, then the process will spend some time building information internally, but ultimately fail (after several seconds) when it tries to write the files.

The command should check that all needed parameters are available up front and fail with an error message that explains what when wrong.

Current output:

Unhandled Exception: System.ArgumentNullException: Value cannot be null.
Parameter name: path1
   at System.IO.Path.Combine(String path1, String path2)
   at SolutionDependencyAnalyzer.DotWriter.WriteProjectDependencyGraph(IDictionary`2 projectDependencies, String graphTitle) in C:\TravailGit\SolutionDependencyAnalyzer\SolutionDependencyAnalyzer\DotWriter.cs:line 27
   at SolutionDependencyAnalyzer.Program.OnExecuteAsync() in C:\TravailGit\SolutionDependencyAnalyzer\SolutionDependencyAnalyzer\Program.cs:line 52
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.InvokeAsync(MethodInfo method, Object instance, Object[] arguments)
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.OnExecute(ConventionContext context)
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.<>c__DisplayClass0_0.<<Apply>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass142_0.<OnExecute>b__0()
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute[TApp](CommandLineContext context)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync[TApp](CommandLineContext context)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync[TApp](IConsole console, String[] args)
   at SolutionDependencyAnalyzer.Program.Main(String[] args) in C:\TravailGit\SolutionDependencyAnalyzer\SolutionDependencyAnalyzer\Program.cs:line 19
   at SolutionDependencyAnalyzer.Program.<Main>(String[] args)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.