efcore icon indicating copy to clipboard operation
efcore copied to clipboard

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

Open chrisAmelinckx opened this issue 9 years ago • 7 comments

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)

chrisAmelinckx avatar Oct 05 '17 15:10 chrisAmelinckx

@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 avatar Oct 05 '17 16:10 ajcvickers

@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 avatar Oct 05 '17 17:10 chrisAmelinckx

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

smitpatel avatar Oct 05 '17 17:10 smitpatel

@smitpatel

.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

chrisAmelinckx avatar Oct 05 '17 17:10 chrisAmelinckx

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

smitpatel avatar Oct 05 '17 17:10 smitpatel

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

chrisAmelinckx avatar Oct 05 '17 19:10 chrisAmelinckx

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

smitpatel avatar Oct 05 '17 21:10 smitpatel