forked from godotengine/godot
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
C#: Switch games to MSBuild Sdks and .NET Standard
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'.
- Loading branch information
Showing
25 changed files
with
454 additions
and
1,040 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Godot.NET.Sdk", "Godot.NET.Sdk\Godot.NET.Sdk.csproj", "{31B00BFA-DEA1-42FA-A472-9E54A92A8A5F}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{31B00BFA-DEA1-42FA-A472-9E54A92A8A5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{31B00BFA-DEA1-42FA-A472-9E54A92A8A5F}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{31B00BFA-DEA1-42FA-A472-9E54A92A8A5F}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{31B00BFA-DEA1-42FA-A472-9E54A92A8A5F}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
35 changes: 35 additions & 0 deletions
35
modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Godot.NET.Sdk.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<Project Sdk="Microsoft.Build.NoTargets/2.0.1"> | ||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
|
||
<Description>MSBuild .NET Sdk for Godot projects.</Description> | ||
<Authors>Godot Engine contributors</Authors> | ||
|
||
<PackageId>Godot.NET.Sdk</PackageId> | ||
<Version>4.0.0</Version> | ||
<PackageVersion>4.0.0-dev2</PackageVersion> | ||
<PackageProjectUrl>https://github.com/godotengine/godot/tree/master/modules/mono/editor/Godot.NET.Sdk</PackageProjectUrl> | ||
<PackageType>MSBuildSdk</PackageType> | ||
<PackageTags>MSBuildSdk</PackageTags> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<NuspecFile>Godot.NET.Sdk.nuspec</NuspecFile> | ||
<GenerateNuspecDependsOn>$(GenerateNuspecDependsOn);SetNuSpecProperties</GenerateNuspecDependsOn> | ||
</PropertyGroup> | ||
|
||
<Target Name="SetNuSpecProperties" Condition=" Exists('$(NuspecFile)') "> | ||
<PropertyGroup> | ||
<NuspecProperties> | ||
id=$(PackageId); | ||
description=$(Description); | ||
authors=$(Authors); | ||
version=$(PackageVersion); | ||
packagetype=$(PackageType); | ||
tags=$(PackageTags); | ||
projecturl=$(PackageProjectUrl) | ||
</NuspecProperties> | ||
</PropertyGroup> | ||
</Target> | ||
</Project> |
22 changes: 22 additions & 0 deletions
22
modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Godot.NET.Sdk.nuspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd"> | ||
<metadata> | ||
<id>$id$</id> | ||
<version>$version$</version> | ||
<description>$description$</description> | ||
<authors>$authors$</authors> | ||
<owners>$authors$</owners> | ||
<projectUrl>$projecturl$</projectUrl> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<license type="expression">MIT</license> | ||
<licenseUrl>https://licenses.nuget.org/MIT</licenseUrl> | ||
<tags>$tags$</tags> | ||
<packageTypes> | ||
<packageType name="$packagetype$" /> | ||
</packageTypes> | ||
<repository url="$projecturl$" /> | ||
</metadata> | ||
<files> | ||
<file src="Sdk\**" target="Sdk" />\ | ||
</files> | ||
</package> |
112 changes: 112 additions & 0 deletions
112
modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.props
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<!-- Determines if we should import Microsoft.NET.Sdk, if it wasn't already imported. --> | ||
<GodotSdkImportsMicrosoftNetSdk Condition=" '$(UsingMicrosoftNETSdk)' != 'true' ">true</GodotSdkImportsMicrosoftNetSdk> | ||
|
||
<GodotProjectTypeGuid>{8F3E2DF0-C35C-4265-82FC-BEA011F4A7ED}</GodotProjectTypeGuid> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<Configurations>Debug;ExportDebug;ExportRelease</Configurations> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
|
||
<GodotProjectDir Condition=" '$(SolutionDir)' != '' ">$(SolutionDir)</GodotProjectDir> | ||
<GodotProjectDir Condition=" '$(SolutionDir)' == '' ">$(MSBuildProjectDirectory)</GodotProjectDir> | ||
<GodotProjectDir>$([MSBuild]::EnsureTrailingSlash('$(GodotProjectDir)'))</GodotProjectDir> | ||
|
||
<!-- Custom output paths for Godot projects. In brief, 'bin\' and 'obj\' are moved to '$(GodotProjectDir)\.mono\temp\'. --> | ||
<BaseOutputPath>$(GodotProjectDir).mono\temp\bin\</BaseOutputPath> | ||
<OutputPath>$(GodotProjectDir).mono\temp\bin\$(Configuration)\</OutputPath> | ||
<!-- | ||
Use custom IntermediateOutputPath and BaseIntermediateOutputPath only if it wasn't already set. | ||
Otherwise the old values may have already been changed by MSBuild which can cause problems with NuGet. | ||
--> | ||
<IntermediateOutputPath Condition=" '$(IntermediateOutputPath)' == '' ">$(GodotProjectDir).mono\temp\obj\$(Configuration)\</IntermediateOutputPath> | ||
<BaseIntermediateOutputPath Condition=" '$(BaseIntermediateOutputPath)' == '' ">$(GodotProjectDir).mono\temp\obj\</BaseIntermediateOutputPath> | ||
|
||
<!-- Do not append the target framework name to the output path. --> | ||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> | ||
</PropertyGroup> | ||
|
||
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props" Condition=" '$(GodotSdkImportsMicrosoftNetSdk)' == 'true' " /> | ||
|
||
<PropertyGroup> | ||
<EnableDefaultNoneItems>false</EnableDefaultNoneItems> | ||
</PropertyGroup> | ||
|
||
<!-- | ||
The Microsoft.NET.Sdk only understands of the Debug and Release configurations. | ||
We need to set the following properties manually for ExportDebug and ExportRelease. | ||
--> | ||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' or '$(Configuration)' == 'ExportDebug' "> | ||
<DebugSymbols Condition=" '$(DebugSymbols)' == '' ">true</DebugSymbols> | ||
<Optimize Condition=" '$(Optimize)' == '' ">false</Optimize> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)' == 'ExportRelease' "> | ||
<Optimize Condition=" '$(Optimize)' == '' ">true</Optimize> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<GodotApiConfiguration Condition=" '$(Configuration)' != 'ExportRelease' ">Debug</GodotApiConfiguration> | ||
<GodotApiConfiguration Condition=" '$(Configuration)' == 'ExportRelease' ">Release</GodotApiConfiguration> | ||
</PropertyGroup> | ||
|
||
<!-- Auto-detect the target Godot platform if it was not specified. --> | ||
<PropertyGroup Condition=" '$(GodotTargetPlatform)' == '' "> | ||
<GodotTargetPlatform Condition=" '$([MSBuild]::IsOsPlatform(Linux))' ">linuxbsd</GodotTargetPlatform> | ||
<GodotTargetPlatform Condition=" '$([MSBuild]::IsOsPlatform(FreeBSD))' ">linuxbsd</GodotTargetPlatform> | ||
<GodotTargetPlatform Condition=" '$([MSBuild]::IsOsPlatform(OSX))' ">osx</GodotTargetPlatform> | ||
<GodotTargetPlatform Condition=" '$([MSBuild]::IsOsPlatform(Windows))' ">windows</GodotTargetPlatform> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<GodotRealTIsDouble Condition=" '$(GodotRealTIsDouble)' == '' ">false</GodotRealTIsDouble> | ||
</PropertyGroup> | ||
|
||
<!-- Godot DefineConstants. --> | ||
<PropertyGroup> | ||
<!-- Define constant to identify Godot builds. --> | ||
<GodotDefineConstants>GODOT</GodotDefineConstants> | ||
|
||
<!-- | ||
Define constant to determine the target Godot platform. This includes the | ||
recognized platform names and the platform category (PC, MOBILE or WEB). | ||
--> | ||
<GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'windows' ">GODOT_WINDOWS;GODOT_PC</GodotPlatformConstants> | ||
<GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'linuxbsd' ">GODOT_LINUXBSD;GODOT_PC</GodotPlatformConstants> | ||
<GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'osx' ">GODOT_OSX;GODOT_MACOS;GODOT_PC</GodotPlatformConstants> | ||
<GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'server' ">GODOT_SERVER;GODOT_PC</GodotPlatformConstants> | ||
<GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'uwp' ">GODOT_UWP;GODOT_PC</GodotPlatformConstants> | ||
<GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'haiku' ">GODOT_HAIKU;GODOT_PC</GodotPlatformConstants> | ||
<GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'android' ">GODOT_ANDROID;GODOT_MOBILE</GodotPlatformConstants> | ||
<GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'iphone' ">GODOT_IPHONE;GODOT_IOS;GODOT_MOBILE</GodotPlatformConstants> | ||
<GodotPlatformConstants Condition=" '$(GodotTargetPlatform)' == 'javascript' ">GODOT_JAVASCRIPT;GODOT_HTML5;GODOT_WASM;GODOT_WEB</GodotPlatformConstants> | ||
|
||
<GodotDefineConstants>$(GodotDefineConstants);$(GodotPlatformConstants)</GodotDefineConstants> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<!-- ExportDebug also defines DEBUG like Debug does. --> | ||
<DefineConstants Condition=" '$(Configuration)' == 'ExportDebug' ">$(DefineConstants);DEBUG</DefineConstants> | ||
<!-- Debug defines TOOLS to differenciate between Debug and ExportDebug configurations. --> | ||
<DefineConstants Condition=" '$(Configuration)' == 'Debug' ">$(DefineConstants);TOOLS</DefineConstants> | ||
|
||
<DefineConstants>$(GodotDefineConstants);$(DefineConstants)</DefineConstants> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<!-- | ||
TODO: | ||
We should consider a nuget package for reference assemblies. This is difficult because the | ||
Godot scripting API is continuaslly breaking backwards compatibility even in patch releases. | ||
--> | ||
<Reference Include="GodotSharp"> | ||
<Private>false</Private> | ||
<HintPath>$(GodotProjectDir).mono\assemblies\$(GodotApiConfiguration)\GodotSharp.dll</HintPath> | ||
</Reference> | ||
<Reference Include="GodotSharpEditor" Condition=" '$(Configuration)' == 'Debug' "> | ||
<Private>false</Private> | ||
<HintPath>$(GodotProjectDir).mono\assemblies\$(GodotApiConfiguration)\GodotSharpEditor.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
</Project> |
17 changes: 17 additions & 0 deletions
17
modules/mono/editor/Godot.NET.Sdk/Godot.NET.Sdk/Sdk/Sdk.targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project> | ||
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" Condition=" '$(GodotSdkImportsMicrosoftNetSdk)' == 'true' " /> | ||
|
||
<PropertyGroup> | ||
<EnableGodotProjectTypeGuid Condition=" '$(EnableGodotProjectTypeGuid)' == '' ">true</EnableGodotProjectTypeGuid> | ||
<ProjectTypeGuids Condition=" '$(EnableGodotProjectTypeGuid)' == 'true' ">$(GodotProjectTypeGuid);$(DefaultProjectTypeGuid)</ProjectTypeGuids> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<!-- | ||
Define constant to determine whether the real_t type in Godot is double precision or not. | ||
By default this is false, like the official Godot builds. If someone is using a custom | ||
Godot build where real_t is double, they can override the GodotRealTIsDouble property. | ||
--> | ||
<DefineConstants Condition=" '$(GodotRealTIsDouble)' == 'true' ">GODOT_REAL_T_IS_DOUBLE;$(DefineConstants)</DefineConstants> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.