Redot-Engine / redot-engine

Redot Engine – Multi-platform 2D and 3D game engine
https://redotengine.org/
MIT License
4.36k stars 179 forks source link

Redot cannot find .net SDK. #669

Open Shiftyhead2 opened 1 week ago

Shiftyhead2 commented 1 week ago

Tested versions

-Reproducible in: Redot mono build

System information

Windows 10 Redot mono build

Issue description

When trying to launch a project with Redot mono build it returns these two errors: Could not resolve SDK "Godot.NET.Sdk". Exactly one of the probing messages below indicates why we could not resolve the SDK. Investigate and resolve that message to correctly specify the SDK. SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" returned null. Unable to find package Godot.NET.Sdk with version (= 4.4.0-dev)

Steps to reproduce

1.Open an empty Redot C# project

  1. Build a C# solution by going Tools -> C# -> Create C# solution 3.Create an empty scene
  2. Run the project

Minimal reproduction project (MRP)

test.zip

Rockdtben commented 1 week ago

I was able to reproduce the issue.

mr-rusty-shackleford commented 1 week ago

I have a bit to learn with regards to contributing a fix to the code here but I can offer more specifics on what the issue is. The first line of the .csproj file associated with the project is: <Project Sdk="Godot.NET.Sdk/4.4.0-dev">

This doesn't exist in nuget.org. Looks like it is now this: <Project Sdk="Godot.NET.Sdk/4.4.0-dev.3">

If you update your .csproj file to include the .3, it should build. Has the "works on my machine" stamp of approval, anyway.

foxication commented 6 days ago

As stated in official documentation

By default, all development builds share a version number, which can cause some issues with caching of the NuGet packages. To solve this issue either use GODOT_VERSION_STATUS to give every build a unique version or delete GodotNuGetFallbackFolder after every build to clear the package cache.

Basically the solution for maintainers is to set the env variable GODOT_VERSION_STATUS to specific version before building the packages (in other words running build_assemblies.py). For example, enter command in powershell:

$env:GODOT_VERSION_STATUS = "dev3"

This will tell MSBuild to find Godot.NET.Sdk/4.4.0-dev.3 in global directories or download from nuget.org

foxication commented 6 days ago

It also implies that maintainers have to upload packages to nuget.org

jardaroh commented 6 days ago

I'm also having this issue.

valkyrienyanko commented 4 days ago

For anyone having this issue here is how you can solve it.

  1. Delete the CSharpFolder in the Redot folder
  2. Copy and paste the CSharpFolder from https://godotengine.org/article/dev-snapshot-godot-4-4-dev-3/ to the Redot folder
  3. Restart Redot. Notice how the issue is gone.

Above steps should auto change your .csproj but just double check your .csproj has the following

<Project Sdk="Godot.NET.Sdk/4.4.0-dev.3">
foxication commented 2 days ago

There is also an alternative solution for you (so there is no need to rewrite .csproj every time you start the Redot engine)

Use the command

dotnet nuget add source "C:\your_location\redot-editor-mono\GodotSharp\Tools\nupkgs" --name "Redot Packages v4.4-dev"

Remember to remove the package source when moving or uninstalling the Redot engine.

dotnet nuget remove source "Redot Packages v4.4-dev"

If you are using Visual Studio, there is another additional way to manage sources: https://learn.microsoft.com/en-us/nuget/consume-packages/install-use-packages-visual-studio#package-sources