Solved: The current .NET SDK does not support targeting .NET Standard 2.0.

I wanted to contribute to Ocelot, however when I tried to build the solution I got this error: "The current .NET SDK does not support targeting .NET Standard 2.0. Either target .NET Standard 1.6 or lower, or use a version of the .NET SDK that supports .NET Standard 2.0."

This blog post details the steps I took to resolve this issue.

Google & Stack Overflow

I googled the error message and found this question on StackOverflow. At first I thought I didn't have the latest .NET SDK installed. I ran dotnet --info and got the following results:

.NET Core SDK (reflecting any global.json):
 Version:   2.1.500
 Commit:    b68b931422
Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17134
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\\Program Files\\dotnet\\sdk\\2.1.500\\
Host (useful for support):
  Version: 2.1.6
  Commit:  3f4f8eebd8
.NET Core SDKs installed:
  2.1.403 \[C:\\Program Files\\dotnet\\sdk\]
  2.1.500 \[C:\\Program Files\\dotnet\\sdk\]
.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.5 \[C:\\Program Files\\dotnet\\shared\\Microsoft.AspNetCore.All\]
  Microsoft.AspNetCore.All 2.1.6 \[C:\\Program Files\\dotnet\\shared\\Microsoft.AspNetCore.All\]
  Microsoft.AspNetCore.App 2.1.5 \[C:\\Program Files\\dotnet\\shared\\Microsoft.AspNetCore.App\]
  Microsoft.AspNetCore.App 2.1.6 \[C:\\Program Files\\dotnet\\shared\\Microsoft.AspNetCore.App\]
  Microsoft.NETCore.App 2.1.5 \[C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App\]
  Microsoft.NETCore.App 2.1.6 \[C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App\]
To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

This told me that I had the latest .NET Core SDK installed. Just in case I tried a repair, however this didn't solve the problem.

Digging in the Solution

One of the comments in the StackOverflow question got me thinking. I found the global.json file in the solution which had the following content:

{
  "projects": ["src", "test"],
  "sdk": {
    "version": "2.1.301"
  }
}

When I ran dotnet --info it told me I didn't have this version installed. I searched for the .NET Core SDK for version 2.1.301 and this led me to this Microsoft page. I downloaded the appropriate SDK version, installed it and voila, problem solved!


Published in: Troubleshooting