I'm trying to run a simple script for unity
public class BirdScript : MonoBehaviour
{
public Rigidbody2D myRigidbody;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Space) == true)
{
myRigidbody.velocity = Vector2.up * 10;
}
}
}
But VSC fails to restore the solution with this error
2023-12-16 10:46:02.365 [info] No .NET SDKs were found.
Download a .NET SDK: https://aka.ms/dotnet-download
Learn about SDK resolution: https://aka.ms/dotnet/sdk-not-found
2023-12-16 10:46:02.367 [info] Additional information of .NET SDKs for diagnostic global.json file: Not found
Host: Version: 6.0.11 Architecture: x64 Commit: 943474ca16
.NET SDKs installed: No SDKs were found.
.NET runtimes installed: Microsoft.NETCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Download .NET: https://aka.ms/dotnet-download
Learn about .NET Runtimes and SDKs: https://aka.ms/dotnet/runtimes-sdk-info
2023-12-16 10:46:02.381 [info] Project system initialization finished. 0 project(s) are loaded, and 1 failed to load.
I've tried deleting all my extensions and re-installing them and also running the C# Dev Kit with Pre-Release version but nothing seems to work. Any ideas?
I have SDK installed with where.exe dotnet showing me C:\Program Files\dotnet\dotnet.exe (also deleted the x64 one)
Here it's visible that SDK is already installed winget install Microsoft.DotNet.SDK.8 Found an existing package already installed. Trying to upgrade the installed package...
Here is the solution that I did
First i followed these steps from reddit
Uninstalled the Unity package named "Visual Studio Code Editor"
Installed the Unity package named "Visual Studio Editor"
Deleted all project filed (all the .csproj and .sln) from my project folder
Selected Visual Studio Code in the external programs in Unity the first two boxes was checked and clicked to regenerate project files.
Removed all the settings related to the C# and Unity extensions from VS Code
Uninstalled all versions of SDK from my computer (you might need to close VS Code and Unity).
Removed all the PATH windows environment variables related to dotnet
Uninstalled Visual Studio and reinstalled (I think you should look the version of Visual Studio related to your Unity version). I only installed two modules from Visual Studio: "Game development with Unity" and ".Net desktop development".
Restarted my computer and everything worked.
After that I did
winget install Microsoft.DotNet.SDK.8
After this the project loaded