Unable to install a few NuGets on .net 5 in a new vanilla asp.net core web project

Crook, Ben 1 Reputation point
2021-08-12T18:46:14.997+00:00

I have some pretty standard NuGets that i've used constantly with asp.net core 3.1 projects. I am starting a new project and was going to use version .net 5.0, yes my project is set to 5.0. whenever I try to install the follow NuGets either cli or gui in VS

these install fine with my new vanilla 5.0 project..

dotnet add %1 package Microsoft.AspNetCore.Identity.EntityFrameworkCore -v 5.0.9
dotnet add %1 package Microsoft.EntityFrameworkCore -v 5.0.9
dotnet add %1 package Microsoft.EntityFrameworkCore.Tools -v 5.0.9
dotnet add %1 package Microsoft.CodeAnalysis.Common -v 3.11.0

however these 3 fail

dotnet add %1 package Microsoft.VisualStudio.Web.CodeGeneration.Design -v 5.0.2
dotnet add %1 package Microsoft.EntityFrameworkCore.SqlServer -v 5.0.9
dotnet add %1 package Microsoft.CodeAnalysis.CSharp.Workspaces -v 3.11.0

with a generic message of "Invalid character in the given encoding. Line 1, position 1.

this is not my project i've created a brand new project.. Also i just updated to latest version of VS community 2019 version 16.11.0 , today thinking well maybe that was it. I also started Vstudio as admin then opened my project.. i'm out of ideas here :( . this seems like a bug with the Microsoft Nuget packages?? anyone else having issues ?

Developer technologies | ASP.NET | ASP.NET Core
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Anonymous
    2021-08-13T02:14:48.817+00:00

    Hi @Crook, Ben I tested in my side with vs2019 and a newly created empty dot net 5 empty project, and I can install the packages you mentioned in the question.

    122951-image.png

    So I'm afraid it may have relationship with you client. I searched for the error message in stackoverflow, and someone else met the same error as yours and high voted answer is recommending to clear the cache, I think you can also try it. You can also see steps below:

    1. In Visual Studio, click: TOOLS > NUGET PACKAGE MANAGER > PACKAGE MANAGER SETTINGS
    2. Select Option NUGET PACKAGE MANAGER > GENERAL
    3. In General, click on button CLEAR ALL NUGET CACHE(S) await a few seconds
    4. Try install again

    If clearing cache doesn't work, I think you could try to install other stable version to rule out the possibility of SDK package issue, and can try to reinstall your vs client. I'll appreciate for any of your reply on the progress, many thanks.


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
    Best Regards,
    TinyWang

    0 comments No comments

  2. Crook, Ben 1 Reputation point
    2021-08-13T11:32:23.693+00:00

    clearing nuget cache fixed it :| , i will say lots of times of pull down a project and it files from gitlab and run it in a test folder. when i do the project needs to restore the nuget packages and i always have issues it seems and have to clear my nuget cache! this is probably the biggest headache with Visual Studio. yeah it's simple to clear it but we shouldn't have to be constantly clearing Nuget cache to fix benign error message like i was seeing.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.