Runar Ovesen Hjerpbakk

Software Philosopher

FindRef - find those references!

.Net is awesome and especially .Net Core Global Tools. Similar to npm install -g you can install tools by executing and easy command:

dotnet tool install --global [name-of-global-tool]

Running the tool is as simple as:

[name-of-global-tool] [arguments]

Just like that you get access to thousands of useful tools, without running installers or browsing to find the correct binary for your system. These tools will run on all platforms supported by .Net Core, both macOS, Windows and Linux. This is truly the power of a cross-platform, open ecosystem. The only pre-requisite is an updated .Net Core SDK installed on your machine.

One such useful tool is FindRef. findref is a simple .Net global tool, written by my man Henrik, designed for searching through a directory of DLLs after a given assembly reference. It supports searching through assemblies targeting netstandard, netcoreapp or .NET Framework.

Install FindRef as a global tool:

dotnet tool install --global findref

And run it like this:

findref [arguments] [options]

So to find all assemblies referencing Newtonsoft.Json in the current directory, use:

$ findref -d . Newtonsoft.Json

+ ImageGallery.dll has a reference to Newtonsoft.Json

In the example above, ImageGallery.dll contained a reference to Newtonsoft.Json.

Use help to see all options:

$ findref -h
Usage:  [arguments] [options]

Arguments:
  assemblyname                the name of the assembly to look for references to. Case insensitive, matches if the FullName is equal to the argument.

Options:
  -?|-h|--help                Show help information
  -d|--directory <DIRECTORY>  the root directory to search through (default: working directory)
  -r|--recursive              search directory recursively
  -v|--verbose                write verbose output to stdout
  -e|--regex                  use assemblyname argument as regex pattern
  -i|--include-unmatched      include unmatched search results in the output

FindRef is a fantastic help if you need to update a reference with a breaking change in a codebase with many loosely coupled modules running in a single process. To give a hypothetical example…