Will Beacon
Will Beacon

Reputation: 81

Visual Studio 2022 .Net6 project build errors due to 'missing' references'

I recently upgraded my solution, and projects to use .Net 6, and switched to using Visual Studio 2022. Since the upgrade, I'm unable to get certain projects to build.

I have compiler errors for missing references, even though the packages appear to be included...

Compiler errorsOther team members can build the branch/code in its current state with Visual Studio 2022, so appears to be a Visual Studio configuration issue on my machine.

I've tried removing, and adding the packages via nuget, cleaning and rebuilding the project. I can't understand why they are not being picked up when the project builds.

Deleted .vs folder from the root of my solution.

Also tried removing the ComponentModelCache folder from...

C:\Users\user\AppData\Local\Microsoft\VisualStudio\17.0_998cb6a9

UPDATE

I've added a further reference to the project via nuget for Microsoft.Extensions.Configuration.

Hear is the contents of the project file, with packages referenced...

enter image description here

Still getting the same build errors. Asked another dev to check out the branch, and build with VS2022 and they were able to.

Upvotes: 2

Views: 2472

Answers (1)

Will Beacon
Will Beacon

Reputation: 81

Thanks for the help/pointers everyone. The cause seems to be Visual Studio was using cached nuget packages when restoring. The solution to this issue seems to be clearing all locally cached nuget packages with the command dotnet nuget locals --clear all

command to clear local nuget folders

More info can be found here...

Clear local nuget folders

Once local/cached packages were cleared, a rebuild of the solution forced a full restore of all nuget packages. The packages were downloaded again, rather than using cached values. The solution finally built!

Hope this helps someone in the future, as I wasted an afternoon of trying to work out what the issue was.

Upvotes: 4

Related Questions