diff --git a/Development/Scripts/Mac/CallBuildTool.sh b/Development/Scripts/Mac/CallBuildTool.sh index 2096a5c57..27f78759a 100755 --- a/Development/Scripts/Mac/CallBuildTool.sh +++ b/Development/Scripts/Mac/CallBuildTool.sh @@ -10,8 +10,7 @@ if [ $testfilesize -le 1000 ]; then fi # Compile the build tool. -xbuild /nologo /verbosity:quiet "Source/Tools/Flax.Build/Flax.Build.csproj" /property:Configuration=Release /property:Platform=AnyCPU /target:Build +dotnet msbuild /nologo /verbosity:quiet "Source/Tools/Flax.Build/Flax.Build.csproj" /property:Configuration=Release /target:Restore,Build /property:RestorePackagesConfig=True /p:RuntimeIdentifiers=osx-x64 # Run the build tool using the provided arguments. -#mono --debug --debugger-agent=transport=dt_socket,server=y,address=127.0.0.1:55555 Binaries/Tools/Flax.Build.exe "$@" -mono Binaries/Tools/Flax.Build.exe "$@" +Binaries/Tools/Flax.Build "$@" diff --git a/Development/Scripts/Mac/XCodeBuild.sh b/Development/Scripts/Mac/XCodeBuild.sh index 6b22e6e3f..3db9ff3ef 100755 --- a/Development/Scripts/Mac/XCodeBuild.sh +++ b/Development/Scripts/Mac/XCodeBuild.sh @@ -2,7 +2,7 @@ # Copyright (c) 2012-2023 Wojciech Figat. All rights reserved # Fix mono bin to be in a path -export PATH=/Library/Frameworks/Mono.framework/Versions/Current/Commands:$PATH +#export PATH=/Library/Frameworks/Mono.framework/Versions/Current/Commands:$PATH echo "Running Flax.Build $*" -mono Binaries/Tools/Flax.Build.exe "$@" +Binaries/Tools/Flax.Build "$@" diff --git a/Source/Engine/Scripting/DotNet/CoreCLR.cpp b/Source/Engine/Scripting/DotNet/CoreCLR.cpp index 959273146..adbc7fb5f 100644 --- a/Source/Engine/Scripting/DotNet/CoreCLR.cpp +++ b/Source/Engine/Scripting/DotNet/CoreCLR.cpp @@ -42,7 +42,12 @@ bool CoreCLR::InitHostfxr(const String& configPath, const String& libraryPath) get_hostfxr_parameters get_hostfxr_params; get_hostfxr_params.size = sizeof(hostfxr_initialize_parameters); get_hostfxr_params.assembly_path = library_path.Get(); - get_hostfxr_params.dotnet_root = nullptr;//dotnetRoot.Get(); + // TODO: implement proper lookup for dotnet instalation folder and handle standalone build of FlaxGame +#if PLATFORM_MAC + get_hostfxr_params.dotnet_root = "/usr/local/share/dotnet"; +#else + get_hostfxr_params.dotnet_root = nullptr; +#endif char_t hostfxrPath[1024]; size_t hostfxrPathSize = sizeof(hostfxrPath) / sizeof(char_t); int rc = get_hostfxr_path(hostfxrPath, &hostfxrPathSize, &get_hostfxr_params); diff --git a/Source/Tools/Flax.Build/Build/DotNet/Builder.DotNet.cs b/Source/Tools/Flax.Build/Build/DotNet/Builder.DotNet.cs index 23355d76f..484b5e9e5 100644 --- a/Source/Tools/Flax.Build/Build/DotNet/Builder.DotNet.cs +++ b/Source/Tools/Flax.Build/Build/DotNet/Builder.DotNet.cs @@ -210,12 +210,27 @@ namespace Flax.Build break; } case TargetPlatform.Mac: - monoRoot = Path.Combine(Globals.EngineRoot, "Source", "Platforms", "Editor", "Mac", "Mono"); - monoPath = Path.Combine(monoRoot, "bin", "mono"); - cscPath = Path.Combine(monoRoot, "lib", "mono", "4.5", "csc.exe"); - referenceAssemblies = Path.Combine(monoRoot, "lib", "mono", "4.5-api"); - referenceAnalyzers = ""; + { +#if USE_NETCORE + var dotnetSdk = DotNetSdk.Instance; + if (dotnetSdk.IsValid) + { + // Use dotnet + cscPath = @$"{dotnetSdk.RootPath}sdk/{dotnetSdk.VersionName}/Roslyn/bincore/csc.dll"; + referenceAssemblies = @$"{dotnetSdk.RootPath}shared/Microsoft.NETCore.App/{dotnetSdk.RuntimeVersionName}/"; + referenceAnalyzers = @$"{dotnetSdk.RootPath}packs/Microsoft.NETCore.App.Ref/{dotnetSdk.RuntimeVersionName}/analyzers/dotnet/cs/"; + } + else +#endif + { + monoRoot = Path.Combine(Globals.EngineRoot, "Source", "Platforms", "Editor", "Mac", "Mono"); + monoPath = Path.Combine(monoRoot, "bin", "mono"); + cscPath = Path.Combine(monoRoot, "lib", "mono", "4.5", "csc.exe"); + referenceAssemblies = Path.Combine(monoRoot, "lib", "mono", "4.5-api"); + referenceAnalyzers = ""; + } break; + } default: throw new InvalidPlatformException(buildPlatform); }