After finally understanding what the .NET Standard is and why we need it, the next thing I wanted to do was investigate which of the many binaries, projects and packages I have used that will continue to work with the .NET standard? Thankfully there are a couple of tools that are going to make this relatively straightforward.
Visual Studio Plugin
- Tools->Extensions and Updates...
- Online >Visual Studio Gallery
- Type in .NET Portability Analyzer and download/install it.
- Visual Studio will probably require a restart
Once installed you have access to two new context menu commands which you activate by right clicking your project:
- Analyze Project Portability
- Portability Analyzer Settings
Executing the Analyze Project Portability against your Visual Studio project will produce an excel sheet which will give you a score ranging from 0-100% compatibility.
In my example I am not 100% compatible which means some portion of this project does not conform to .NET Standard, clicking on the Details tab give more specific reasons on what is failing.
Command Line Tool
If you are not inclined to use Visual Studio or you are more interested in collecting these results during your continuous or official builds you could also take advantage of the command line tool (it is the same engine to the VS plugin). To get this setup, do the following:
- Navigate to the .NET Portability Analyzer site on GitHub.
- Click on the releases link
- Scroll down to the Downloads and pull down the ApiPort.zip file (you may have to Unblock the zip).
- Unzip the file, the ApiPort.exe is the command line tool
Now you can execute the command line script as follows:
C:\debug\ApiPort.exe analyze -f C:\test\Test.dll
As with the Visual Studio plugin this produces and excel sheet by default, however, this example is again only selecting defaults for comparison. For a complete list of targets you can run the following command, versions marked with an asterisk are the defaults:
So if I want to change the target to say, an older version of the standard like 1.3, then I can run a command like this:
C:\debug\ApiPort.exe analyze -f C:\test\Test.dll -t ".NET Standard, Version-1.3"
This just makes integration with an existing build process much more straightforward, you could probably even wire this up to alarm if someone uses an API with limited supported.
Checking NuGet Packages
There is a very useful community project called I Can Has .NET Core, which allows you to upload your projects packages.config, project.json and paket.dependencies for analysis, the site then builds a visualization of the package and determines whether the equivalent .NET standard versions are available on nuget.org. As an added bonus you can point the site at your GitHub repo and it will automatically scour it for packages as well.
Your dependencies are categorized as Supported, Known Replacement Available, Unsupported and Not Found.