This issue occurs when you are trying to a built a .NET Core app with specific runtime version such as winx-64 or win10-64 or winx-32 or win10-32. The error might be displayed as shown below
error NETSDK1134: Building a solution with a specific RuntimeIdentifier is not supported. If you would like to publish for a single RID, specifiy the RID at the individual project level instead.
This error occurs only due to reasons as discussed above. To solve this, all you need to change your dotnet build command such that it builds without runtime configuration. In mycase this was easily solved by running the below command
dotnet build --configuration Release --framework net7.0