Efcore: Visual Studio Build requires global.json edit for sdk version 2.0.0

Created on 5 Oct 2017  路  7Comments  路  Source: dotnet/efcore

Following the readme instructions then opening the solution in Visual Studio shows many errors due to global.json pointing to the .Net Core 2.1 preview

Visual Studio Error:
Severity    Code    Description Project File    Line    Suppression State
Error       The current .NET SDK does not support targeting .NET Core 2.0.  Either target .NET Core 1.1 or lower, or use a version of the .NET SDK that supports .NET Core 2.0. dotnet-ef.Tests C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.TargetFrameworkInference.targets  112 

Steps to reproduce

Follow current readme instructions
Open the EFCore.sln

Further technical details

EF Core version: 2.0.0
Operating system: Windows
IDE: Visual Studio 2017 15.3

Workaround:

Edit global.json to this
{ "sdk" : { "version" : "2.0.0" }}

3 errors will be left

Right click the solution and select: Restore NuGet Packages (give it a few moments for all projects)

closed-question

All 7 comments

@chrisAmelinckx Did you follow the instructions here: https://github.com/aspnet/EntityFrameworkCore/wiki/Getting-and-Building-the-Code In particular, the part about setting the path?

@ajcvickers correct... I did follow the instructions and did set the path, then opened Visual Studio.
But still the error about the SDK version would come up.
After I tried the workaround of overriding the global.json on the solution directory, then the errors went away.
I just realized that global.json is not part of the repo, it must auto generated by the build process (?).
In any case, if this is verified, we might need to add it to the wiki/Getting-and-Building-the-Code

@chrisAmelinckx - Can you run dotnet --info on your command line and post output here?

@smitpatel
```$ dotnet --info
.NET Command Line Tools (2.0.0)

Product Information:
Version: 2.0.0
Commit SHA-1 hash: cdcd1928c9

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

Microsoft .NET Core Shared Framework Host

Version : 2.0.0
Build : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d
```

That is the cause of error.
You need to add preview SDK in your PATH variable appearing before dotnet installed in Program Files.
Once your dotnet --info shows 2.1.0 dotnet version, solution will work fine. It is bit ugly to set up everything especially combined with other projects. I don't like to spoil my global env variables with preview stuff so I do in following way (I generally use PowerShell terminal, commands can be converted to any shell)

git clone ...
./build /t:Restore
$env:PATH="$env:USERPROFILE/.dotnet/x64;"+$env:PATH
.\EFCore.sln

That works @smitpatel, perhaps a ref from the readme would be good.
Thanks.

I updated wiki with steps to modify PATH locally. Hope it helps future users.

Was this page helpful?
0 / 5 - 0 ratings