In my case , there was a message on top of Visual Studio that some components were missing to build the project.
Im my case it was .net 6.0 sdk. After installing, the message was gone.