forked from godotengine/godot
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3.2 New csproj style with backport of Godot.NET.Sdk
This is a cherry-pick of ced77b1 with several 3.2 specific alterations. There are a lot of build issues coming from old style projects. At this point fixing every single one of those would require adding patch after patch to the project file, which is a considerable amount work and makes the csproj even more bloated than it already is. As such I decided this effort would be better spent back-porting the Sdk style support that's already available in 4.0-dev to the 3.2 branch. This will prevent many issues, but it will also introduce other benefits, among them: - While target framework stays as .NET Framework v4.7.2, it can be changed to .NET Standard 2.0 or greater if desired. - It makes it much easier to add future patches. They are added to Godot.NET.Sdk and the only change required in Godot code is to update the Sdk version to use. - Default Godot define constants are also backported, which fixes IDE issues with the preprocessor. There are a few differences in the changes applied during patching of the csproj compared to 4.0 with the purpose of preventing breaking builds: - 'TargetFramework' stays net472 both for new projects and when importing old ones. It can be manually changed to netstandard 2.0+ if desired though. The following features are enabled by default for new projects. Enabling them in imported projects may result in errors that must be fixed manually: - 'EnableDefaultCompileItems' is disabled as it can result in undesired C# source files being included. Existing include items are kept. As long as 'EnableDefaultCompileItems' remains disabled, Godot will continue taking care of adding and removing C# files to the csproj. - 'GenerateAssemblyInfo' is disabled as it guarantees a build error because of conflicts between the existing 'AssemblyInfo.cs' and the auto-generated one. - 'Deterministic' is disabled because it doesn't like wildcards in the assembly version (1.0.*) that was in the old 'AssemblyInfo.cs'. Of importance: This is a breaking change. A great effort was put in avoiding build errors after upgrading a project, but there may still be exceptions. This also breaks forward compatibility. Projects opened with Godot 3.2.3 won't work out of the box with older Godot versions. This was already the case with changes introduced in 3.2.2. Albeit C# support in 3.2.x was still labeled as alpha, we've been trying to treat it as stable for some time. Still the amount of problems this change solves justifies it, but no more changes that break project compatibility are to be introduced from now on (at least for 3.x).
- Loading branch information
Showing
23 changed files
with
658 additions
and
628 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
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>3.2.3</Version> | ||
<PackageVersion>3.2.3</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> |
119 changes: 119 additions & 0 deletions
119
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,119 @@ | ||
<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))' ">x11</GodotTargetPlatform> | ||
<GodotTargetPlatform Condition=" '$([MSBuild]::IsOsPlatform(FreeBSD))' ">x11</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)' == 'x11' ">GODOT_X11;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> | ||
|
||
<PropertyGroup Condition=" '$(AutomaticallyUseReferenceAssemblyPackages)' == '' and '$(MicrosoftNETFrameworkReferenceAssembliesLatestPackageVersion)' == '' "> | ||
<!-- Old 'Microsoft.NET.Sdk' so we reference the 'Microsoft.NETFramework.ReferenceAssemblies' package ourselves. --> | ||
<AutomaticallyUseReferenceAssemblyPackages>true</AutomaticallyUseReferenceAssemblyPackages> | ||
<MicrosoftNETFrameworkReferenceAssembliesLatestPackageVersion>1.0.0</MicrosoftNETFrameworkReferenceAssembliesLatestPackageVersion> | ||
<GodotUseNETFrameworkRefAssemblies>true</GodotUseNETFrameworkRefAssemblies> | ||
</PropertyGroup> | ||
</Project> |
34 changes: 34 additions & 0 deletions
34
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,34 @@ | ||
<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> | ||
|
||
<!-- Backported from newer Microsoft.NET.Sdk version --> | ||
<Target Name="IncludeTargetingPackReference" BeforeTargets="_GetRestoreSettingsPerFramework;_CheckForInvalidConfigurationAndPlatform" | ||
Condition=" '$(GodotUseNETFrameworkRefAssemblies)' == 'true' and '$(TargetFrameworkMoniker)' != '' and '$(TargetFrameworkIdentifier)' == '.NETFramework' and '$(AutomaticallyUseReferenceAssemblyPackages)' == 'true' "> | ||
<GetReferenceAssemblyPaths | ||
TargetFrameworkMoniker="$(TargetFrameworkMoniker)" | ||
RootPath="$(TargetFrameworkRootPath)" | ||
TargetFrameworkFallbackSearchPaths="$(TargetFrameworkFallbackSearchPaths)" | ||
BypassFrameworkInstallChecks="$(BypassFrameworkInstallChecks)" | ||
SuppressNotFoundError="true"> | ||
<Output TaskParameter="FullFrameworkReferenceAssemblyPaths" PropertyName="_FullFrameworkReferenceAssemblyPaths"/> | ||
</GetReferenceAssemblyPaths> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="$(MicrosoftNETFrameworkReferenceAssembliesLatestPackageVersion)" IsImplicitlyDefined="true" Condition="'$(_FullFrameworkReferenceAssemblyPaths)' == ''"/> | ||
</ItemGroup> | ||
</Target> | ||
</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
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.