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):
OS Name: Windows
OS Version: 10.0.17134
OS Platform: Windows
Base Path: C:\Program Files\dotnet\sdk\2.1.500\
Host (useful for support):
.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:
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" ],
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!
You could only change the “version” entry to either “2.1.500” or “2.1.403” in your global.json file
Thanks for your comment. Agreed, that would have solved it as well. I opted to download the version in use by the solution as I was working on an open source project and wasn’t sure what impact changing the version in the codebase would have on the rest of the solution.