dotnet in Rider: cannot resolve symbol 'Microsoft'
Asked Answered
A

1

8

In Rider 2020.1.3 on macOS Catalina. I'm not normally a C# dev, so apologies for incorrect terminology.

This is a .NET api containerized with Docker. Rider is randomly seeming to lose connection to the dotnet core libraries. It will be fine and then I'll walk away and come back and get "cannot resolve symbol 'Microsoft'" or "cannot resolve symbol 'System'" on all the imports (see attached screenshot), which of course trickles down to none of their methods being recognized either. When I build it at this point I get this error:

Microsoft.PackageDependencyResolution.targets(208, 5): [NETSDK1004] Assets file '/app/[applicationName]/obj/project.assets.json' not found. Run a NuGet package restore to generate this file.

Doing a NuGet package restore tells me all packages are restored, and the file it mentions exists at that location (however, it says 'no index' next to it, but not sure what that means).

The first time it happened seemed to be because the SDK I had installed locally (3.1) was different than the one used in the project (2.2). I installed 2.2 on my machine and that fixed the issue for a bit.

The second time it happened, later in the day after the first time, it seemed to be because Rider was favoring the 3.1 install in the Toolset and Build settings. So I deleted the 3.1 install from my system, and it fixed the issue for about a day.

I get back on today and it's happened again. I've tried various things I've found Googling around: unchecking 'Use Resharper Build,' adding some things to the .dockerignore, verifying there's not a %20 in the top-level dir as a result of the clone.

I am not sure what info would be relevant at this point; please let me know if some parts of the code or file structure are needed to help troubleshoot. The root of the entire project contains the directory for the API referenced here, the directory for the app, which is React, and the docker-compose.yml. The API has its own Dockerfile, as does the app.

Screenshot of unrecognized imports

Edit:

What ended up fixing it was going through these steps to remove dotnet completely and then redownloading 2.2

Aram answered 11/6, 2020 at 15:44 Comment(2)
.net core allows side by side installations of multiple versions. learn.microsoft.com/en-us/dotnet/core/tools/… specifying -f (--framework) should help picking a framework of choice, such as learn.microsoft.com/en-us/dotnet/core/tools/dotnet-build Also try specifing --force it forces all the dependencies to be resolved.Atheist
This may also happen due to long paths on Windows. When I passed limit for number of characters, Rider showed me the same error.Egad
O
11

Please go to the setting > build, Execution, Deployment > Toolset and Build and then you can see like this.

enter image description here

After that, you have to change use MSBuild version the default MSBuild version might be Auto detected (##) .... then click the combo box and please select a version that supports you.

enter image description here

The 4.0 is batter in my case. after select and apply them, you can see a success message from Rider. otherwise, Rider shows an error. if you have an error please try another option. thanks.

Oppression answered 6/1, 2021 at 20:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.