Ben Rubin
Ben Rubin

Reputation: 7331

Visual Studio new project is missing files/folders

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.

enter image description here

enter image description here

Note the missing dependencies in the project below.

enter image description here

Now I run dotnet restore

enter image description here

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

  1. Is it normal to have to run dotnet restore immediately after creating a new ASP Core project? If not, what's causing this problem for me?
  2. How do I get rid of the version conflicts?

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.

enter image description here

Upvotes: 1

Views: 1359

Answers (1)

Lex Li
Lex Li

Reputation: 63133

  1. Nothing to fear. Absolutely normal. And when you call 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.

  1. Nobody tries to get rid of that. MSBuild has its internal logic on calculation and clearly this issue has been known and harmless (except your eyes) so far.

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

Related Questions