Reputation: 7331
I'm using Visual Studio 2017 to create a new ASP.NET Core application, but the project that is created doesn't compile because of missing dependencies. Following another user's suggestion, I ran dotnet restore
. That caused the application to be able to compile and run, but now I'm getting a bunch of version conflicts, which I'd like to get rid of
Here are screenshots of how I'm creating the project.
Note the missing dependencies in the project below.
Now I run dotnet restore
Now the application compiles, but I get a lot of version conflicts
1> Encountered conflict between 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.AppContext.dll' and 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.appcontext\4.3.0\ref\netstandard1.6\System.AppContext.dll'. Choosing 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.AppContext.dll' because AssemblyVersion '4.2.0.0' is greater than '4.1.0.0'.
1> Encountered conflict between 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.Collections.dll' and 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.collections\4.3.0\ref\netstandard1.3\System.Collections.dll'. Choosing 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.Collections.dll' because AssemblyVersion '4.1.0.0' is greater than '4.0.10.0'.
1> Encountered conflict between 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.Collections.Concurrent.dll' and 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.collections.concurrent\4.3.0\ref\netstandard1.3\System.Collections.Concurrent.dll'. Choosing 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.Collections.Concurrent.dll' because AssemblyVersion '4.0.14.0' is greater than '4.0.10.0'.
1> Encountered conflict between 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.Collections.NonGeneric.dll' and 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.collections.nongeneric\4.3.0\ref\netstandard1.3\System.Collections.NonGeneric.dll'. Choosing 'Reference:C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.Collections.NonGeneric.dll' because AssemblyVersion '4.1.0.0' is greater than '4.0.1.0'.
... and so on
My two questions are
dotnet restore
immediately after creating a new ASP Core project? If not, what's causing this problem for me?UPDATE
In case anyone else has the same problem and stumbles across this question, I found that for some reason, my "restore missing packages" option wasn't enabled. Once I enabled it, I was able to build my project successfully without doing dotnet restore
first.
Upvotes: 1
Views: 1359
Reputation: 63133
dotnet build
at command line, dotnet restore
would be called implicitly. That's a .NET SDK 2.0 change. If you are forced to run dotnet restore
manually, that becomes another issue, which means your .NET Core SDK does not take effect. You need to learn global.json
and create such a file in your project to force using the latest SDK on this machine, like Scott Hanselman wrote. Visual Studio 2017 might require you to use Restore NuGet Packages menu item. Visual Studio for Mac or JetBrains Rider would automatically restore the packages.
Do make good use of Google and GitHub, and you can find all the officially information made public by Microsoft.
The presence of project.assets.json
is an indication that the legacy of package.json
is still there in the build process.
Upvotes: 1