Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems after install Net Core 2.0 building in Visual Studio 2015

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.

like image 503
Fidel Orozco Avatar asked Nov 21 '25 01:11

Fidel Orozco


1 Answers

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.

like image 174
MindingData Avatar answered Nov 22 '25 17:11

MindingData



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!