Disclaimer: I am a consultant at Amazon Web Services, and this is my personal blog. The opinions expressed here are solely mine and do not reflect the views of Amazon Web Services (AWS). Any statements made should not be considered official endorsements or statements by AWS.
I just got this error while publishing my first ASP.NET Core application in Self-Contained Deployment mode.
One liner solution to this problem is - Just repair your Visual Studio.
Though I took some screenshots of repairing steps, I thought attaching those screenshots here might help you.
After restarting the system, you will find that issue has been fixed. :)