3
votes

I been testing Net Core 1.0.1 and building prototypes with VS 2015.

After I installed Net Core 2.0, if I try to build a API Web Core App from VS, I got the obvious error "The dependency Microsoft.NETCore.App >= 1.0.1 could not be resolved". Then I edit the JSON file referencing to .NetCore 2.0.0, and try to restore with Nuget, but it says that everything is OK, even when clearly showing VS in references that 2.0 is lost.

I proceed to use brute force and open Nuget Manager and install manually Microsoft.NETCore.App 2.0, apparently succeeding. But that does not resolve the first error, just updating to "...to 2.0.0 could not be resolved" and add the new mystifying "Project MyTest does not have lock file. Please run 'dotnet restore' to generate new lock file". Running from the CLI 'dotnet restore' it complains that one or more packages are incompatible with .NetCoreApp,Version=v2.0.

Gee!... Is Visual Studio 2015 so...doomed? Can not it be used with Net Core 2.0? I really do not have space in my machine to try the shiny Visual Studio 2017.

2
"For Visual Studio users: You need to update to the latest versions of Visual Studio to use .NET Core 2.0. You will need to install the .NET Core 2.0 SDK separately for this update. (Visual Studio 2017 15.3+, Visual Studio for Mac, Visual Studio Code — C# Extension)" source blogs.msdn.microsoft.com/dotnet/2017/08/14/…Matjaž Mav

2 Answers

3
votes

You cannot use .NET Core 2.0 inside Visual Studio 2015. The easy way to remember is that if it's project.json, it's inside VS 2015, if it's CSProj, it's inside VS 2017.

But to go further, If you wish to keep using VS 2015 on your .NET Core 1.0.1 projects, you can do this, but it just takes a bit of fidgeting as seen here : https://dotnetcoretutorials.com/2017/02/17/developing-two-versions-net-core-sdk-side-side/

Essentially in the root of your .NET Core 1.0.1 solution, you need to create a file called global.json. Inside this file, you need the following :

{
  "sdk": {
    "version": "1.0.0-preview2-003131"
  }
}

Where version is the SDK version for your "old" .NET Core installed on your machine. If you are on windows and you are unsure, you can go to your .NET install folder (Usually C:\Program Files\dotnet\dotnet.exe) and the folders there correspond to the versions you have installed.

Without the global.json file, VS and the command line automatically use the newest version installed on your machine.

3
votes

It has always been stated that Visual Studio 2015 was not truly compatible with .NET Core and even more so with .NET Core 2 since the base requirement is Visual Studio 2017 (15.3 )

the .JSON format has been long deprecated back to .csproj file which is now using msbuild.exe.