523

I'm trying to use nopCommerce(Which is written in .NET Core) but when I want to run the project I face 52 Errors telling me Run a nuget package restore

Assets file ~\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. Nop.Web.MVC.Testsote

when I use the right click on the solution and selecting Restore Nuget Packages I get this message:

All packages are already installed and there is nothing to restore.

but those 52 Errors are still there and in Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution there is nothing installed on the solution,also I Recently updated my VS2017 to 15.5.4

xpt
  • 20,363
  • 37
  • 127
  • 216
NeverTrust
  • 5,487
  • 2
  • 13
  • 16
  • Have you provided consent to NuGet to restore? Go to tools, options, search for NuGet, and the check the "Allow NuGet..." option. – imps Jan 26 '18 at 00:54
  • 32
    If anyone is on a Mac, we had this problem and fixed it by removing spaces in the repository path (which was created during the git pull): My%20Project becomes MyProject. – David Hague Jun 03 '20 at 16:08
  • May take a look here at MS Docs with various workarounds (updated May 2018): https://learn.microsoft.com/en-us/nuget/consume-packages/package-restore-troubleshooting With nuget things never run smooth as click and go! – hB0 Jun 30 '20 at 16:31
  • MS guys trying to help again 2019 with same issues: https://learn.microsoft.com/en-us/nuget/consume-packages/package-restore – hB0 Jun 30 '20 at 16:33
  • 2
    @DavidHague thank you for the tip on fixing the repo path with spaces on a Mac - that was my problem - thanks! – AVH Sep 14 '20 at 02:40
  • 2
    @DavidHague saved a lot of time. Thank you. Space was the issue. – Prabhat Ranjan Mar 29 '21 at 15:15
  • Right-clicking the solution and selecting "Restore NuGet Packages" worked for me. – Nick Westgate Jul 20 '21 at 00:06
  • Thanks @DavidHague, you solution of removing "%20" worked with me. – Ahmed Mostafa Apr 05 '22 at 12:11
  • @DavidHague Your solution works for the same issue on Windows as well. Thanks! – RidicCoder Apr 12 '22 at 00:54
  • For me the problem was to remove the spacing (%20) that came along git clone. So I changed my project root directory from My%20Project to My Project and all worked as expected. I am using Intellij Rider on Windows. – Serhat Dec 19 '22 at 08:54
  • I opened the project properties and nudged the target framework a minor version back (or up depending where you are) saved the project (file was created) and nudged it back to where it was... easy peasy – Null Mar 22 '23 at 12:42

41 Answers41

843

To fix this error from Tools > NuGet Package Manager > Package Manager Console simply run:

dotnet restore

The error occurs because the dotnet cli does not create the all of the required files initially. Doing dotnet restore adds the required files.

Matteo Migliore
  • 925
  • 8
  • 22
Mostafa Bouzari
  • 9,207
  • 3
  • 16
  • 26
  • 37
    This was also the fix for the build server. Added a Command Line step to run "dotnet restore" after normal NuGet restore. – Mark Jun 08 '18 at 09:18
  • 37
    You may do it from MSBuild also: msbuild MySolution.sln /t:Restore – Der_Meister Jul 13 '18 at 08:24
  • 6
    @Der_Meister's solution to add the /t:Restore option worked for me, however, I had to build the solution twice (two separate build steps). First with the /t:Restore option and then again without it. – Michael Jul 19 '18 at 16:43
  • 27
    @Michael, try msbuild MySolution.sln /t:Restore;Build – Der_Meister Jul 20 '18 at 10:56
  • 4
    This is the best, perfect and working solution. Thanks so much – Wai Yan Hein Aug 01 '18 at 15:07
  • 1
    This fix the issue with Appveyor, thanks. I don't understand why we need to do the restore manually. I tough that the build was automatically doing the restore :/ – Nordes Sep 08 '18 at 13:35
  • 17
    If you have more than one solution file, you need to do `dotnet restore solutionfilename.sln` – Ed Harrod Sep 13 '18 at 08:28
  • Do you have to run it many times? Do you need to combine it with normal nuget restore? Do you have to run it as administrator? – Anders Lindén Jan 16 '19 at 08:05
  • This solution was the fix for me. Just don't forget to reopen VS afterwards. – zoidbeck Apr 15 '19 at 08:16
  • 1
    @Der_Meister had a solution that almost worked for me in Azure Devops Build pipeline. /t:Restore fixed nuget issue but didn't build. Changed slightly to /t:Restore;Clean;Build and everything worked. – BitPusher16 Jul 11 '19 at 16:37
  • This worked for me. For those saying it doesnt work make sure you are opening the command window from the sln directory or better yet use the package manager console when the sln is open in VS – James Blackburn Aug 22 '19 at 08:13
  • 1
    I had to create a subfolder named "package", before issuing "dotnet restore", for it to work. – Starnuto di topo Sep 17 '19 at 10:28
  • 5
    Microsoft strongly recommends using `-t:build -restore` instead of `/t:restore;build` See here: https://learn.microsoft.com/nuget/reference/msbuild-targets#restoring-and-building-with-one-msbuild-command – oderibas Apr 15 '20 at 21:29
  • 3
    it does not work at all, and how would it be a "perfect solution" since this kind of thing should be dealt by the ide itself...it's a brand new solution, it does not make any sens – user7082181 May 20 '20 at 07:09
  • Came to reply to this. If you are using AzureDevops Pipeline builds, you don't need a separate task for this, just add /t:Restore to MSBuild arguments on the solution build task. – Akos Feb 03 '21 at 07:51
  • If you are running this from an ordinary command prompt (e.g. on a build server like CruiseControl.Net), make sure you are in the folder that contains your .csproj or other project files. – humbads Feb 08 '21 at 15:20
  • I had the same problem in Jetbrains Rider IDE. I opened up the terminal in Rider and ran dotnet restore. It fixed the problem immediately – Noah Jun 25 '21 at 06:40
  • Thanks! Running the command 'dotnet restore' fixed my project errors. – Sanushi Salgado Aug 27 '21 at 06:31
212

In my case the error was the GIT repository. It had spaces in the name, making my project unable to restore

If this is your issue, just rename the GIT repository when you clone

git clone http://Your%20Project%20With%20Spaces newprojectname
Sebastian Castaldi
  • 8,580
  • 3
  • 32
  • 24
  • 7
    This answer should be at the beginning of the post not at the end. Solved my issue. – CodeWarrior Apr 16 '19 at 01:18
  • 4
    in my case i just renamed my physical folder by remove %20 and replace it with normal space and every thing is working well – hosam hemaily Sep 25 '19 at 08:29
  • 1
    The %20's in the folder name was the issue. Was so confused why it was failing. Thank you so much! – NiallMitch14 Oct 15 '19 at 10:27
  • 1
    Agree, this was the problem (and solution) for me too. Aditionally, creating a new .NET Core MVC project in a folder with '%20' also failed to properly create the project file itself (I had to manually include the created Model, View and Controller folders in the project for instance). That should have been my first clue project creation was not done properly. – Céryl Wiltink Dec 29 '19 at 09:44
  • 1
    This was it - this seems to be an issue in TFS/Azure DevOps where spaeces are allowed. – lohithbb Oct 13 '20 at 13:51
  • When you work for big organizations, you don't get to choose the project name, usually is another team (most likely not developers) that chooses these names with spaces, by all means, if you have rights to create/modify the project name go for it, but like in my case you don't, then the above solution works – Sebastian Castaldi May 21 '22 at 16:04
84

In case when 'dotnet restore' not works, following steps may help:

  1. Visual Studio >> Tools >> Options >> Nuget Manager >> Package Sources
  2. Unchecked any third party package sources.
  3. Rebuild solution.
prisan
  • 1,251
  • 12
  • 9
  • 6
    I recently encountered this issue for Identity server Quickstart #1: Securing an API using Client Credentials and the above solution worked for me. – Tharindu Jayasinghe May 04 '19 at 12:19
  • Thank you! I actually removed one source that was not relevant anymore (from another solution) and on the _nuget.org_ and _MSVS Offline Packages_ sources I clicked the **Update** button. After this `dotnet restore` worked. – CPHPython Jul 10 '19 at 10:33
  • Thank you, that was it! – tdracz Sep 06 '19 at 17:34
  • 1
    If you need 3rd party package sources or yours own organization over AzureDevOPs then follow this instruction: https://learn.microsoft.com/en-us/azure/devops/artifacts/nuget/nuget-exe?view=azure-devops – hB0 Jun 30 '20 at 16:02
  • 2
    In my case there was an entry for Microsoft offline packages and it seemed to be invalid. Took ages to find that out. Thanks. – Robert S. Oct 29 '20 at 10:39
  • 1
    Yes, I have added some custom NuGet references from the package manager, hence only not resolving that problem. Now works – Hemalatha M.R. Nov 20 '20 at 07:25
  • Or perhaps investigate WHY it isnt working instead of just blindly hacking away at your package sources... my guess is in your case you had one that was broken and it was causing YOUR restore to fail. In which case its not an issue with HAVING third party package sources; that would be ridiculous. Run dotnet restore from the nuget package manager as suggested above to see what is actually failing. – computrius Mar 26 '21 at 16:51
  • @computrius What's your solution then? Please share with everyone. – prisan Apr 09 '21 at 11:09
  • @prisan Looks like my comment hit close to home and you got offended and blinded to the fact that it IS the solution. Plus, you clearly didn’t read past the first sentence. – computrius Apr 10 '21 at 15:58
  • Works as s charm ! – Dany Nov 22 '21 at 09:27
70

To those with the same issue as me in Azure DevOps / VSTS environment encountering a similar message:

C:\Program Files\dotnet\sdk\2.2.104\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(208,5): Error NETSDK1004: Assets file '...\obj\project.assets.json' not found. Run a NuGet package restore to generate this file

Add /t:Restore to your MSBuild Arguments in Build Solution.

In Azure DevOps build pipeline, add /t:Restore here:

enter image description here

robnick
  • 1,720
  • 17
  • 27
taylorswiftfan
  • 1,371
  • 21
  • 35
  • 1
    Might be a rare case, but I had to also remove a property from my .csproj... Remove this if it exists: true... now all is right in the world again. – Tyler Dec 31 '20 at 20:20
  • 1
    Just wanted to acknowledge that this still works today in off-prem ADO with Git. I spent hours troubleshooting a pipeline for a VS 2022 .Net 7 build. This solved my issue - so thank you from one Swiftie to another (I have a 14YO daughter so it's required apparently). – Donny McCoy Dec 20 '22 at 02:11
  • This appeared to fix my pipeline, but then I was getting an empty artifact. It ended up being that an SSRS project was recently added to the solution, but the build server didn't have SSRS support yet. – Design.Garden Apr 22 '23 at 23:40
  • 1
    This fixed the issue for me, thanks. I've added an image to the solution to make it really clear where to add the build arg. – robnick Jul 16 '23 at 04:23
51

Closing and re-opening Visual Studio solved this issue for me, once I had made sure the NuGet packages had been restored as per other answers posted here.

Edit: Sometimes just trying to build again fixes the problem.

OutstandingBill
  • 2,614
  • 26
  • 38
  • Can't believe this worked for me too after doing dotnet restore and only after this – Gaspa79 Oct 09 '18 at 15:08
  • I had some separate connectivity issues on my work LAN that were inhibitive for NuGet. Rebooting my PC resolved the issue! – Neo Aug 19 '19 at 08:23
  • This is really not an answer because sometimes you use CLI tools to `get` and `build` and you don't open VS. I know why it works with VS - because VS automatically resolves project dependencies. – T.S. Oct 24 '19 at 19:48
  • @T.S. the question is tagged with "Visual Studio 2017", so I'd say this _is_ an answer. You raise an interesting point though, that the problem lies with VS resolving dependencies. If you have any more information on what's going wrong, I'm sure it would make interesting reading : ) – OutstandingBill Oct 25 '19 at 00:48
  • +1. You caught me! With VS, oh well. His version 15.5 was buggy. I think 15.5/15.6 had host of issues for reference resolution. Now, here is the answer https://stackoverflow.com/a/58548856/1704458 – T.S. Oct 25 '19 at 01:17
25

For me when i did - dotnet restore still error was occurring.

I went to

1 Tool -> NuGet Package Maneger -> Package Manager settings -> click on "Clear all NuGet Cache(s)"

2 dotnet restore

resolved issues.

Homer
  • 7,594
  • 14
  • 69
  • 109
Speed
  • 387
  • 1
  • 4
  • 12
14

In visual studio 2017 please do following steps:

1) select Tool=>Options=>NuGet Package Manager=> Package Sources then uncheck Microsoft Visual Studio Offline Packages Option. enter image description here

2) now open Tool=>NuGet Package Maneger=>Package Manager Console. 3) execute command in PM>dotnet restore.

Hope its working...

Manoj Gupta
  • 456
  • 4
  • 9
11

It was mentioned earlier but I just wanted to re-emphasize the importance of not have space anywhere in your pathing! This is what was getting me. You've been warned.

Mike Homol
  • 481
  • 5
  • 19
  • this is what helped me - I had spaced in my path to my projects and after I removed them, it fixed it! – Mark Jul 22 '22 at 00:21
10

If this error occurs as part of a build in Azure DevOps (TFS) and your build already has a NuGet restore task, this error may indicate the NuGet restore task was not able to restore all packages, especially if you use a custom package source (such as an internal NuGet server). Adding /t:Restore;Build to the MSBuild Arguments seems to be one way to resolve the error, but this asks MSBuild to perform an additional NuGet restore operation. I believe this succeeds because MSBuild uses the custom package source configured in Visual Studio. A preferable solution is to fix the NuGet restore task.

To configure a custom package source for the NuGet restore task:

  1. Create a NuGet.config file that lists all of the package sources (Microsoft Visual Studio Offline Packages, nuget.org, and your custom package source) and add it to source control.
  2. In the Nuget restore task under Feeds to use: select the option Feeds in my NuGet.config.
  3. Provide the path to NuGet.config.
  4. Remove the /t:Restore;Build option from the MSBuild task.

Additional information is available here.

Jeremiah Mercier
  • 451
  • 5
  • 18
9

For me I upgraded NuGet.exe from 3.4 to 4.9 because 3.4 doesn't understand how to restore packages for .NET Core.

For details please see dotnet restore vs. nuget restore with teamcity

user8128167
  • 6,929
  • 6
  • 66
  • 79
  • Yes - I found this when we started migrating old .Net Framework projects across to the new `.csproj` project format. – StuartLC Jan 06 '20 at 17:28
  • To update nuget.exe... run from a VS command prompt: `nuget.exe update -self` It was only AFTER updating to the latest nuget, and then doing dotnet Restore that these errors went away for me – James S Aug 11 '23 at 15:35
8

Solved by adding /t:Restore;Build to MSBuild Arguments

Abdulsamet ILERI
  • 155
  • 2
  • 10
  • For me it does not work to do /t:Restore;Build but /t:Restore /t:Build, but thanks, your answer helped me ! – R13mus Feb 12 '21 at 09:00
  • This has [already been said](https://stackoverflow.com/a/55733937/542251) – Liam Oct 29 '21 at 08:51
8

You will get required packages from "https://api.nuget.org/v3/index.json". Add this in Package Resources. Also make sure other packages are unchecked for time being. And Click Restore Nuget Package on Solution Explorer enter image description here

Yogesh Dangre
  • 181
  • 1
  • 4
7

Select Tools > NuGet Package Manager > Package Manager Console

And then Run:

dotnet restore <project or solution name>
Andre Mesquita
  • 879
  • 12
  • 25
6

Nothing above worked for me. But simply deleting all 'bin' and 'obj' folders did the trick.

alexbk66
  • 362
  • 1
  • 3
  • 12
  • This issue happend for me when i worked on a Dockerfile. deleting those folders made the dotnet restore in the container work properly. – Johannes May 16 '19 at 15:15
5

This problem happening when your build tool is not set to do restore on projects set to use PackageReference vs packages.config and mostly affect Net Core and Netstandard new style projects.

When you open Visual Studio and build, it resolves this for you. But if you use automation, CLI tools, you see this issue.

Many solutions are offered here. But all you need to remember, you need to force restore. In some instances you use dotnet restore before build. If you build using MsBuild just add /t:Restore switch to your command.

Bottom line, you need to see why restoring can't be activated. Either bad nuget source or missing restore action, or outdated nuget.exe, or all of the above.

T.S.
  • 18,195
  • 11
  • 58
  • 78
  • 1
    `/t:Restore` turned out to be the fix to my problem in a heterogeneous solution (framework, core, and standard projects mixed). The standard/core projects were failing with the error until I used this approach. – jpt Dec 29 '21 at 13:38
5

You can go for : Tools > NuGet Package Manager > Package Manager Console

And then Run:

dotnet restore

seven
  • 97
  • 1
  • 4
4

little late to the answer but seems this will add value. Looking at the error - it seems to occur in CI/CD pipeline.

Just running "dotnet build" will be sufficient enough.

dotnet build

dotnet build runs the "restore" by default.

Sunny Sharma
  • 4,688
  • 5
  • 35
  • 73
  • 1
    Also can be achieved by adding step ".NET core" to pipeline (before build), and selecting "dotnet restore" command from dropdown. I'm talking specifically about VSTS pipeline here. – Lech Osiński Dec 11 '18 at 13:57
4

I lost several hours on this error in Azure DevOps when I set the 'Visual Studio Build' task in a build pipeline to build an individual project in my solution, rather than the whole solution.

Doing that means that DevOps either doesn't build any (or possibly some, I'm not sure which) of the projects referenced by the project you've targeted for the build, and therefore those projects won't have their project.json.asset files generated, which then causes this issue.

The solution for me was to swap from using the VS Build task to the MSBuild task. Using the MSBuild task for an individual project correctly builds any projects referenced by the project you're building and eliminates this error.

tomRedox
  • 28,092
  • 24
  • 117
  • 154
3

If simply restoring NuGet packages does not work make sure in Tools -> Options -> NuGet Package Manager -> General under Package Restore that the "Allow NuGet to download missing packages" is checked.

Then Restore NuGet Packages again OR just REBUILD after deleting obj and bin folders.

Nick Kovalsky
  • 5,378
  • 2
  • 23
  • 50
NexX
  • 303
  • 3
  • 13
2

run your VS as administrator after that in package manager console run dotnet restore.

2

When using VSTS, check your global.json file. I had entered the sdk version as just "2.2" which caused a parse error (but not when building locally). Adding the full version, "2.2.104" solved the problem.

Rob Minnis
  • 21
  • 1
2

I have same problem and dotnet resotre not work for me. I Install this component:

enter image description here

and the run dotnet resotre and the problem has solved.

Arian
  • 12,793
  • 66
  • 176
  • 300
2

I did not have any NuGet in my CLI/C++. VS2022 built fine. However, MSBuild did not work giving me error NETSDK1004: Assets file ... obj\project.assets.json' not found. Run a NuGet package restore to generate this file.

The solution to my issue was removing the following from the vcxproj file.

<EnableManagedPackageReferenceSupport>true</EnableManagedPackageReferenceSupport>

I suppose changing true to false might work. I removed the line and MSBuild now works.

user3097514
  • 319
  • 2
  • 6
1

In my case, I had the following added to my *.csproj files to fully remove obj and bin folders on 'Clean'. Apparently, it was the culprit. Got rid of that and viola, all started to work again. Now I'm using the "Clean Bin" extension instead. Hope this might help anyone who is running into this issue, and none of the mentioned fixes works.

<Target Name="SuperClean" AfterTargets="Clean">
    <!-- Remove obj folder -->
    <RemoveDir Directories="$(BaseIntermediateOutputPath)" />
    <!-- Remove bin folder -->
    <RemoveDir Directories="$(BaseOutputPath)" />
</Target>    
Ε Г И І И О
  • 11,199
  • 1
  • 48
  • 63
0

Another one, if by any chance you're using Dropbox, check for Conflicted in file names, do a search in your repo and delete all those conflicted files.

This may have happened if you have moved the files around.

Jose A
  • 10,053
  • 11
  • 75
  • 108
0

Cause of this defect: you have to remove the injected Nuget in file explorer. Solution: Once you remove that Nuget in your system, then remove from following location. select Tool=>Options=>NuGet Package Manager=> Package Sources then uncheck Microsoft Visual Studio Offline Packages Option

balaji s
  • 62
  • 4
0

This worked for me: added this package source: Microsoft and .net https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/ then run "dotnet restore" in the console

Henry L
  • 48
  • 8
0

In my case I had a problem with the Available Package Sources. I had move the local nuget repository folder to a new path but I did not update it in the Nuget Available Package Sources. When I've correct the path issue, update it in the Available Package Sources and after that everything (nuget restor, etc) was working fine.

0

Very weird experience I have encountered!

I had cloned with GIT bash and GIT cmd-Line earlier, I encountered the above issues.

Later, I cloned with Tortoise-GIT and everything worked as expected.

May be this is a crazy answer, but trying with this once may save your time!

Bikram
  • 483
  • 6
  • 16
0

Seen this after adding a WinForms Core 3.1 project (from project templates) on VS-2019 vs 16.4.0 and trying to run it out of the box. Clean or Rebuild the entire solution did not work.

I just reloaded my solution.. that is File/Close Solution and then reopening it and rebuilding it solved the problem.

Goodies
  • 1,951
  • 21
  • 26
0

For me it turned out to be a nuget source credentials problem. I had recently changed my password for accessing a nexus server and visual studio was still using the old password when trying to access a nuget on that server through the windows credential manager. To fix it, I had to delete the entry for those outdated credentials in the credential manager and after, when I did a nuget restore, it prompted me for a password letting me enter the new password, which got saved in the credential manager again. You can access the credential manager from the cmd line using CmdKey.exe.

J. Volkya
  • 993
  • 3
  • 14
  • 33
0

I received one message on Azure DevOps about don't find file

i need to create this on my YAML deployment file, AFTER BUILD TASK

- task: NuGetCommand@2
  inputs:
    command: 'restore'
    restoreSolution: '**\*.sln'
    feedsToUse: 'config'
    noCache: false
Felipe Augusto
  • 1,341
  • 1
  • 16
  • 18
0

My issue was the build configuration platform was mismatched. Once, I changed "Any CPU" to "x64", I was able to publish.

enter image description here

LawMan
  • 3,469
  • 1
  • 29
  • 32
0

What worked for me when I got this error was adding a global.json file but that may be related to using Paket instead of Nuget.

Steve
  • 127
  • 1
  • 8
0

Had a similar issue. Turned out that I did not have access to %APPDATA%\Local\Temp\NuGetScratch\lock

Once I had access I could run nuget restore, but everything did start working.

m_a_s
  • 240
  • 2
  • 6
0

In my case it was .net6 project and the build happening on DevOps windows-2019 agent.

enter image description here

Solution: windows-2022 can build .net6.

tymtam
  • 31,798
  • 8
  • 86
  • 126
0

I haven't found anywhere the method suggested by Microsoft which is to delete the "packages" folder.

Source: Troubleshooting package restore errors

You may encounter build errors due to missing files, with a message saying to use NuGet restore to download them. However, running a restore might say, "All packages are already installed and there is nothing to restore." In this case, delete the packages folder (when using packages.config) or the obj/project.assets.json file (when using PackageReference) and run restore again. If the error still persists, use nuget locals all -clear or dotnet nuget locals all --clear from the command line to clear the global-packages and cache folders as described on Managing the global packages and cache folders.

usilo
  • 305
  • 2
  • 10
0

Wow. This one has clearly been giving people trouble (including myself). As others have noted, it seems that a large number of failure cases may lead to a similar set of evidence.

Anyway, for me I was getting this "project.assets.json not found" error when trying to publish. After trying many of the suggestions found here, and elsewhere, and losing a half-day, I found something that got me unstuck and I thought I'd add my solution in case it helps anyone.

  1. Ensure that the directory "{PROJECT-ROOT}\obj\publish\browser-wasm" exists, creating it if needed.

  2. Find these 5 files in your "{PROJECT-ROOT}\obj" directory:

    project.assets.json
    project.nuget.cache
    {PROJECT-NAME}.csproj.nuget.dgspec.json
    {PROJECT-NAME}.csproj.nuget.g.props
    {PROJECT-NAME}.csproj.nuget.g.targets
  1. Copy those 5 files into "{PROJECT-ROOT}\obj\publish\browser-wasm", overwriting them if needed.

  2. If the dependencies for any projects that are dependencies of your project have changed then you should do steps 1, 2, and 3 for each of those projects as well.

  3. Restart Visual Studio.

This got me unstuck and I am now able to publish. However, I do need to re-do this each time I add new Dependencies to my project.

Todd
  • 99
  • 1
  • 4
0

To fixed this issue. First you have to close the Visual Studio, then restart again in administrative mode.

Create an new project or run your older project. Then Go

Tools > NuGetPackage Package Manager > Package Manager Console

An console will be open in below

Then put a command

dotnet restore 

It will fixed all your problem.

  • Thank you for your interest in contributing to the Stack Overflow community. This question already has quite a few answers—including one that has been extensively validated by the community. Are you certain your approach hasn’t been given previously? **If so, it would be useful to explain how your approach is different, under what circumstances your approach might be preferred, and/or why you think the previous answers aren’t sufficient.** Can you kindly [edit] your answer to offer an explanation? – Jeremy Caney Jul 27 '23 at 00:19
-1

I got the error when I created a lambda in dot net core in VS2017. What worked for me was to unload the project and load it back.

boms
  • 91
  • 1
  • 11
-1

Try this (It worked for me):

  • Run VS as Administrator
  • Manual update NuGet to most recent version
  • Delete all bin and obj files in the project.
  • Restart VS
  • Recompile