| 1793 | hostfxr_run_app_fn hostfxr_run_app; |
| 1794 | |
| 1795 | bool InitHostfxr() |
| 1796 | { |
| 1797 | const ::String csharpLibraryPath = Globals::BinariesFolder / TEXT("FlaxEngine.CSharp.dll"); |
| 1798 | const ::String csharpRuntimeConfigPath = Globals::BinariesFolder / TEXT("FlaxEngine.CSharp.runtimeconfig.json"); |
| 1799 | if (!FileSystem::FileExists(csharpLibraryPath)) |
| 1800 | LOG(Fatal, "Failed to initialize .NET runtime, missing file: {0}", csharpLibraryPath); |
| 1801 | if (!FileSystem::FileExists(csharpRuntimeConfigPath)) |
| 1802 | LOG(Fatal, "Failed to initialize .NET runtime, missing file: {0}", csharpRuntimeConfigPath); |
| 1803 | const FLAX_CORECLR_STRING& libraryPath = FLAX_CORECLR_STRING(csharpLibraryPath); |
| 1804 | |
| 1805 | // Get path to hostfxr library |
| 1806 | get_hostfxr_parameters get_hostfxr_params; |
| 1807 | get_hostfxr_params.size = sizeof(get_hostfxr_parameters); |
| 1808 | get_hostfxr_params.assembly_path = libraryPath.Get(); |
| 1809 | #if PLATFORM_MAC |
| 1810 | ::String macOSDotnetRoot = TEXT("/usr/local/share/dotnet"); |
| 1811 | #if defined(__x86_64) || defined(__x86_64__) || defined(__amd64__) || defined(_M_X64) |
| 1812 | // When emulating x64 on arm |
| 1813 | const ::String dotnetRootEmulated = macOSDotnetRoot / TEXT("x64"); |
| 1814 | if (FileSystem::FileExists(dotnetRootEmulated / TEXT("dotnet"))) { |
| 1815 | macOSDotnetRoot = dotnetRootEmulated; |
| 1816 | } |
| 1817 | #endif |
| 1818 | const FLAX_CORECLR_STRING& finalDotnetRootPath = FLAX_CORECLR_STRING(macOSDotnetRoot); |
| 1819 | get_hostfxr_params.dotnet_root = finalDotnetRootPath.Get(); |
| 1820 | #else |
| 1821 | get_hostfxr_params.dotnet_root = nullptr; |
| 1822 | #endif |
| 1823 | FLAX_CORECLR_STRING dotnetRoot; |
| 1824 | String dotnetRootEnvVar; |
| 1825 | if (!Platform::GetEnvironmentVariable(TEXT("DOTNET_ROOT"), dotnetRootEnvVar) && FileSystem::DirectoryExists(dotnetRootEnvVar)) |
| 1826 | { |
| 1827 | dotnetRoot = FLAX_CORECLR_STRING(dotnetRootEnvVar); |
| 1828 | get_hostfxr_params.dotnet_root = dotnetRoot.Get(); |
| 1829 | } |
| 1830 | #if !USE_EDITOR |
| 1831 | const String bundledDotnetPath = Globals::ProjectFolder / TEXT("Dotnet"); |
| 1832 | if (FileSystem::DirectoryExists(bundledDotnetPath)) |
| 1833 | { |
| 1834 | dotnetRoot = FLAX_CORECLR_STRING(bundledDotnetPath); |
| 1835 | #if PLATFORM_WINDOWS_FAMILY |
| 1836 | dotnetRoot.Replace('/', '\\'); |
| 1837 | #endif |
| 1838 | get_hostfxr_params.dotnet_root = dotnetRoot.Get(); |
| 1839 | } |
| 1840 | #endif |
| 1841 | String platformStr; |
| 1842 | switch (PLATFORM_TYPE) |
| 1843 | { |
| 1844 | case PlatformType::Windows: |
| 1845 | case PlatformType::UWP: |
| 1846 | if (PLATFORM_ARCH == ArchitectureType::x64) |
| 1847 | platformStr = "Windows x64"; |
| 1848 | else if (PLATFORM_ARCH == ArchitectureType::ARM64) |
| 1849 | platformStr = "Windows ARM64"; |
| 1850 | else |
| 1851 | platformStr = "Windows x86"; |
| 1852 | break; |
no test coverage detected