-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C#: Switch games to MSBuild Sdks and .NET Standard #40595
C#: Switch games to MSBuild Sdks and .NET Standard #40595
Conversation
On an empty project, with this PR and the above Mono on Ubuntu 20.04, I get this error when building:
Running Also, when building after restoring, I got this message:
With both Mono and .NET Core 3.1 (
As before, running |
@aaronfranke There was a recent fix. Did you test with the commit 4a30289 included? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new list of define constants includes:
Why not also include GODOT_PC
, GODOT_MOBILE
, and GODOT_WEB
? These are essentially unions of operating systems, which we already define, so it should be easy to add these.
The architecture/bits and texture compression are of low importance, so it's fine to ditch them... and that covers everything!
@neikeq If you rebased this PR, then that fix would be included :) |
Godot.NET.Sdk ------------- Godot uses its own custom MSBuild Sdk for game projects. This new Sdk adds its own functionality on top of 'Microsoft.NET.Sdk'. The new Sdk is resolved from the NuGet package. All the default boilerplate was moved from game projects to the Sdk. The default csproj for game project can now be as simple as: ``` <Project Sdk="Godot.NET.Sdk/4.0.0-dev2"> <PropertyGroup> <TargetFramework>netstandard2.1</TargetFramework> </PropertyGroup> </Project> ``` Source files are included by automatically so Godot no longer needs to keep the csproj in sync when creating new source files. Define constants ---------------- Godot defines a list of constants for conditional compilation. When exporting games, this list also included engine 'features' and platform 'bits'. There were a few problems with that: - The 'features' constants were only defined when exporting games. Not when building the game for running in the editor player. - If the project was built externally by an IDE, the constants wouldn't be defined at all. The new Sdk assigns default values to these constants when not built from the Godot editor, i.e.: when built from an IDE or from the command line. The default define constants are determined from the system MSBuild is running on. However, it's not possible for MSBuild to determine the set of supported engine features. It's also not possible to determine if a project is being built to run on a 32-bit or 64-bit Godot executable. As such the 'features' and 'bits' constants had to be removed. The benefit of checking those at compile time was questionable, and they can still be checked at runtime. The new list of define constants includes: - GODOT - GODOT_<PLATFORM> Defaults to the platform MSBuild is running on. - GODOT_<PC/MOBILE/WEB> - TOOLS When building with the 'Debug' configuration (editor and editor player). - GODOT_REAL_T_IS_DOUBLE Not defined by default unless $(GodotRealTIsDouble) is overriden to be 'true'. .NET Standard ------------- The target framework of game projects was changed to 'netstandard2.1'.
86a591e
to
ced77b1
Compare
Re-based to latest master, added |
I still get this error message when building an empty project without .NET Core, though it still builds and runs.
Does this mean that .NET Core is now required as a part of Godot moving to .NET Standard? So you need both Mono and .NET Core for Godot? If .NET Core is not required, then it should not throw an error. If it is required, that should be documented. Also, should |
That's unrelated to this PR. That should probably be changed to a simple print rather than an error. It's printed when the selected build tool cannot be found (dotnet CLI is the default now) and Godot will try to fallback to a different one.
I decided to keep it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand every line of this but it works well and I have no further concerns.
Thanks! |
Is there a plan to backport this into the 3.x versions or would that be too difficult or not worth the effort? I've run into helpful nuget packages requiring netstandard2.1 which are unfortunately impossible to use with Godot 3.x. |
@AndrewMorsillo Probably not. It's not really reasonable to expect major features like this to be backported to stable branches, since that's not the point of stable branches and major changes like this have a high chance of breaking things. If you want to use new features, you will simply have to upgrade to new versions when they come out. EDIT: Also, this PR already has known compatibility breakages (though they are minor). |
Godot.NET.Sdk
Godot uses its own custom MSBuild Sdk for game projects. This new Sdk adds its own functionality on top of 'Microsoft.NET.Sdk'.
The new Sdk is resolved from the NuGet package.
All the default boilerplate was moved from game projects to the Sdk. The default csproj for game project can now be as simple as:
Source files are included by automatically so Godot no longer needs to keep the csproj in sync when creating new source files.
Closes godotengine/godot-proposals#315
Define constants
Godot defines a list of constants for conditional compilation. When exporting games, this list also included engine 'features' and platform 'bits'.
There were a few problems with that:
The new Sdk assigns default values to these constants when not built from the Godot editor, i.e.: when built from an IDE or from the command line. The default define constants are determined from the system MSBuild is running on.
However, it's not possible for MSBuild to determine the set of supported engine features.
It's also not possible to determine if a project is being built to run on a 32-bit or 64-bit Godot executable.
As such the 'features' and 'bits' constants had to be removed.
The benefit of checking those at compile time was questionable, and they can still be checked at runtime.
The new list of define constants includes:
GODOT
GODOT_<PLATFORM>
Defaults to the platform MSBuild is running on.
TOOLS
When building with the 'Debug' configuration (editor and editor player).
GODOT_REAL_T_IS_DOUBLE
Not defined by default unless $(GodotRealTIsDouble) is overriden to be 'true'.
.NET Standard
The target framework of game projects was changed
to 'netstandard2.1'.
Closes godotengine/godot-proposals#339