From 3d09423d9fbb85f433cf2a6cfa2a472883ac3d90 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Fri, 2 Aug 2019 18:06:37 +0300 Subject: [PATCH] [netcore] Use mono-netcore to run real world apps using `dotnet run` (mono/mono#15942) So currently we have two .NET Core: 1) `mono-repo/.dotnet` - we use it to bootstrap and build stuff (the SDK version is specified in `global.json`) - if you open `netcore/Makefile` it's referred there as `$(DOTNET)` variable. 2) `mono-repo/netcore/.dotnet` - it's just a runtime + CoreFX libs (it doesn't contain SDK stuff, templates, msbuild, etc) - we use it only to run tests because this runtime is synchronized with corefx tests in `eng/Versions.prop` file which is updated by a bot and `netcore/shared` sources for our System.Private.CoreLib also depend on that exact runtime version (the sources also updated by the bot). This PR introduces a rule to copy mono bits to the `mono-repo/.dotnet` folder to be able to run real world apps (at your own risk) using mono-netcore (so when you run `mono-root/.dotnet/.dotnet run -c Release` for an app - even MSBuild will use mono runtime to build that app). However in theory we need exact SDK for the runtime version we have but I have no idea where and how to get one. BTW, currently MSBuild crashes when it's powered by mono on `$(DOTNET) build` command for a hello world. ``` monoeg_assertion_message mono_domain_assembly_preload invoke_assembly_preload_hook ... at <0xffffffff> at System.Reflection.RuntimeAssembly:GetExportedTypes <0x000a2> at AssemblyInfoToLoadedTypes:ScanAssemblyForPublicTypes <0x0008e> ``` Commit migrated from https://github.com/mono/mono/commit/d0aa0310ee386433a9ef0b4c15ac07c928211bcb --- src/mono/netcore/Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/mono/netcore/Makefile b/src/mono/netcore/Makefile index 902c0c4..6cc2710 100644 --- a/src/mono/netcore/Makefile +++ b/src/mono/netcore/Makefile @@ -9,6 +9,10 @@ ROSLYN_VERSION:= $(shell cat ../eng/Versions.props | sed -n 's/.*MicrosoftNetCo # Extracted from https://dotnetcli.blob.core.windows.net/dotnet/aspnetcore/Runtime/master/latest.version ASPNETCOREAPP_VERSION := 3.0.0-preview-18614-0151 +# runtime version used by $(DOTNET) - local .net core sdk to bootstrap stuff +# it doesn't match NETCOREAPP_VERSION +BOOTSTRAP_RUNTIME = $(shell ls ../.dotnet/shared/Microsoft.NETCore.App) + ifeq ($(HOST_PLATFORM),win32) PLATFORM_AOT_SUFFIX := .dll PLATFORM_AOT_PREFIX := @@ -95,6 +99,12 @@ run-aspnet-sample: prepare cp System.Private.CoreLib/bin/$(COREARCH)/System.Private.CoreLib.dll sample/AspNetCore/bin/Debug/netcoreapp3.0/$(RID)/publish/ COMPlus_DebugWriteToStdErr=1 ./dotnet --fx-version "$(ASPNETCOREAPP_VERSION)" sample/AspNetCore/bin/Debug/netcoreapp3.0/$(RID)/publish/AspNetCore.dll +# makes $(DOTNET) to use mono runtime (to run real-world apps using '$(DOTNET) run') +patch-local-dotnet: prepare + cp ../mono/mini/.libs/libmonosgen-2.0$(PLATFORM_AOT_SUFFIX) ../.dotnet/shared/Microsoft.NETCore.App/$(BOOTSTRAP_RUNTIME)/$(PLATFORM_AOT_PREFIX)coreclr$(PLATFORM_AOT_SUFFIX) + cp System.Private.CoreLib/bin/$(COREARCH)/System.Private.CoreLib.dll ../.dotnet/shared/Microsoft.NETCore.App/$(BOOTSTRAP_RUNTIME) + cp System.Private.CoreLib/bin/$(COREARCH)/System.Private.CoreLib.pdb ../.dotnet/shared/Microsoft.NETCore.App/$(BOOTSTRAP_RUNTIME) + # COREHOST_TRACE=1 SHAREDRUNTIME := shared/Microsoft.NETCore.App/$(NETCOREAPP_VERSION) -- 2.7.4