Peter Wone
Peter Wone

Reputation: 18765

How and where to resolve ASP.NET Core references

I have a project generated by

dotnet new Aurelia

that works find on my home system, but when transferred to my work system via git sync, Visual Studio Code reports the following:

file: 'file:///c%3A/Users/REDACTED/AppData/Local/Temp/.NETCoreApp%2CVersion%3Dv2.0.AssemblyAttributes.cs'
severity: 'Error'
message: 'The type 'TargetFrameworkAttribute' exists in both 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [Dox]'
at: '4,46'
source: ''

Possibly I have two versions of the run-time on this system, or perhaps home and office have two different versions; how would I check? And what's the prescribed remedy?


Okay I installed the latest SDK but now it's complaining that it can't find MVC and a bunch of other dependencies. What now?


Updating the SpaTemplates wasn't completely successful and I still have the errors. Any other ideas?

Upvotes: 0

Views: 703

Answers (1)

Peter Wone
Peter Wone

Reputation: 18765

The 2.0 SDK has not been installed on the workstation exhibiting the problems. Download and install the latest SDK.


You have unsatisfied dependencies and you almost certainly have out of date SPA templates. Open your project in VS Code and open the Terminal window by typing Ctrl+` then update your SPA templates like so:

dotnet new --install Microsoft.AspNetCore.SpaTemplates::*

When that completes VS Code will ask you whether you want to restore dependencies. Click the Restore button to begin. When the dust settles, MVC etc should be found and any remaining errors will be your own.


My last suggestion stands but it appears there's a problem with versions of NuGet prior to 4.3 and probably the quickest thing to do is get Visual Studio 2017 Community for the NuGet manager it has. You will need all the updates, I suspect. This also may help - Is there a way to automatically update nuget.exe in the .nuget folder when using package restore?

Confirmed solution

Apply the latest update to Visual Studio Community, reboot and then load the project in Visual Studio Community. The restore will occur automatically and when the status bar says the restore is complete, the project is good to go. If you load it in VS Code you will find the errors are gone and the skies are clear.

Upvotes: 2

Related Questions