Try to edit envrionment Variables.
Right click on This PC -> Properties -> Advanced System Settings -> Advanced -> Environment Variables -> System Variables
Add [install path] C:Program Filesdotnet
to the variable path.
Restart visual studio.
If it does not solve this problem, you can refer to this answer.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…