diff --git a/.gitignore b/.gitignore
index fa697b57d3fb..e111924f4219 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,7 @@ syntax: glob
# Tool Runtime Dir
.dotnet/
+.dotnet-mono/
.packages/
.tools/
diff --git a/src/mono/mono.proj b/src/mono/mono.proj
index 5d545525a2da..32b1c1052641 100644
--- a/src/mono/mono.proj
+++ b/src/mono/mono.proj
@@ -9,6 +9,8 @@
dotnet
..\..\.dotnet
$(LocalDotnetDir)\$(DotNetExec)
+ ..\..\.dotnet-mono
+ $(LocalMonoDotnetDir)\$(DotNetExec)
.cmd
.sh
<_CoreClrFileName Condition="'$(TargetsWindows)' == 'true'">coreclr.dll
@@ -56,6 +58,12 @@
+
+
+
+
@@ -88,25 +96,19 @@
-
-
-
- $([System.IO.Directory]::GetDirectories("$(LocalDotnetDir)\shared\Microsoft.NETCore.App")[0])
-
+
+
+ <_LocalDotnetFiles Include="$(LocalDotnetDir)\**\*.*" />
<_MonoRuntimeArtifacts Include="$(BinDir)\*.*" />
-
+
+
-
-
-
-
-
-
+
@@ -115,9 +117,9 @@
<_MonoRuntimeArtifacts Include="$(BinDir)\*.*" />
+
+ DestinationFolder="$(CoreClrTestCoreRoot)" />
@@ -129,8 +131,16 @@
-
-
+
+
+
+
+
+
+
@@ -139,25 +149,15 @@
-
+
-
-
-
-
-
+
+
-
-
-
-
-
-
+
-
+
diff --git a/src/mono/netcore/Makefile b/src/mono/netcore/Makefile
index 57aa39985a66..de287eb85f90 100644
--- a/src/mono/netcore/Makefile
+++ b/src/mono/netcore/Makefile
@@ -1,38 +1,49 @@
-DOTNET=../../../.dotnet/dotnet
+DOTNET := $(shell bash init-tools.sh | tail -1)
+# DOTNET_MONO is a copy of DOTNET (local .dotnet) with Mono Runtime bits (see patch-mono-dotnet rule)
+DOTNET_MONO = ../../../.dotnet-mono/dotnet
-# run sample using local .dotnet (will be patched with Mono Runtime)
-run-sample:
- $(DOTNET) msbuild /t:RunSample ../mono.proj
+CORECLR_TESTS_CONFIG=Release
+MONO_RUNTIME_CONFIG=Release
+
+# auto detect configurations for mono runtime and coreclr tests
+ifeq ($(words $(wildcard ../../../artifacts/bin/mono/*.*.*)), 1)
+ MONO_RUNTIME_CONFIG := $(word 3,$(subst ., ,$(notdir $(wildcard ../../../artifacts/bin/mono/*.*.*))))
+endif
+
+ifeq ($(words $(wildcard ../../../artifacts/tests/coreclr/*.*.*)), 1)
+ CORECLR_TESTS_CONFIG := $(word 3,$(subst ., ,$(notdir $(wildcard ../../../artifacts/tests/coreclr/*.*.*))))
+endif
+
+MONO_PROJ=/p:CoreClrTestConfig=$(CORECLR_TESTS_CONFIG) /p:Configuration=$(MONO_RUNTIME_CONFIG) ../mono.proj
+
+# run sample using local .dotnet-mono
+run-sample: patch-mono-dotnet
+ COMPlus_DebugWriteToStdErr=1 $(DOTNET_MONO) run -c Debug -p sample/HelloWorld
-# run sample using dotnet from PATH
run-sample-coreclr:
- dotnet run -c Release -p sample/HelloWorld -f netcoreapp3.1
+ $(DOTNET) run -c Debug -p sample/HelloWorld
+
+bcl corelib:
+ $(DOTNET) msbuild /t:BuildCoreLib $(MONO_PROJ)
runtime:
- $(DOTNET) msbuild /t:Build ../mono.proj
+ $(DOTNET) msbuild /t:Build $(MONO_PROJ)
-# temp: makes $(DOTNET) to use mono runtime (to run real-world apps using '$(DOTNET) run')
-patch-local-dotnet:
- $(DOTNET) msbuild /t:PatchLocalDotnet ../mono.proj
-
-restore-local-dotnet:
- $(DOTNET) msbuild /t:RestoreLocalDotnet ../mono.proj
+# call it if you want to use $(DOTNET_MONO) in this Makefile
+patch-mono-dotnet:
+ $(DOTNET) msbuild /t:PatchLocalMonoDotnet $(MONO_PROJ)
# run specific coreclr test, e.g.:
-# make run-tests-coreclr CoreClrTest="bash ../../artifacts/tests/coreclr/OSX.x64.Checked/JIT/opt/InstructionCombining/DivToMul/DivToMul.sh"
+# make run-tests-coreclr CoreClrTest="bash ../../artifacts/tests/coreclr/OSX.x64.Release/JIT/opt/InstructionCombining/DivToMul/DivToMul.sh"
run-tests-coreclr:
- $(DOTNET) msbuild /t:RunCoreClrTest /p:CoreClrTest="$(CoreClrTest)" ../mono.proj
+ $(DOTNET) msbuild /t:RunCoreClrTest /p:CoreClrTest="$(CoreClrTest)" $(MONO_PROJ)
# run all coreclr tests
run-tests-coreclr-all:
- $(DOTNET) msbuild /t:RunCoreClrTests ../mono.proj
-
-# show summary for coreclr tests
-tests-coreclr-summary:
- $(DOTNET) msbuild /t:CoreClrTestsSummary ../mono.proj
+ $(DOTNET) msbuild /t:RunCoreClrTests $(MONO_PROJ)
# run 'dotnet/performance' benchmarks
# e.g. 'make run-benchmarks BenchmarksRepo=/prj/performance'
# you can append BDN parameters at the end, e.g. ` -- --filter Burgers --keepFiles`
run-benchmarks: patch-local-dotnet
- $(DOTNET) msbuild /t:RunBenchmarks /p:BenchmarksRepo=$(BenchmarksRepo)
\ No newline at end of file
+ $(DOTNET) msbuild /t:RunBenchmarks /p:BenchmarksRepo=$(BenchmarksRepo)
diff --git a/src/mono/netcore/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/mono/netcore/System.Private.CoreLib/System.Private.CoreLib.csproj
index 388eea847857..45e60e8e8713 100644
--- a/src/mono/netcore/System.Private.CoreLib/System.Private.CoreLib.csproj
+++ b/src/mono/netcore/System.Private.CoreLib/System.Private.CoreLib.csproj
@@ -143,6 +143,7 @@
+
diff --git a/src/mono/netcore/System.Private.CoreLib/src/Mono/Console.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/Mono/Console.Mono.cs
new file mode 100644
index 000000000000..396dfecf3784
--- /dev/null
+++ b/src/mono/netcore/System.Private.CoreLib/src/Mono/Console.Mono.cs
@@ -0,0 +1,19 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Diagnostics;
+
+namespace Internal
+{
+ // Some CoreCLR tests use it for internal printf-style debugging in System.Private.CoreLib
+ public static class Console
+ {
+ public static void Write(string? s) => DebugProvider.WriteCore(s);
+
+ public static void WriteLine(string? s) => Write(s + Environment.NewLineConst);
+
+ public static void WriteLine() => Write(Environment.NewLineConst);
+ }
+}
\ No newline at end of file
diff --git a/src/mono/netcore/init-tools.sh b/src/mono/netcore/init-tools.sh
new file mode 100644
index 000000000000..ae2ed159a060
--- /dev/null
+++ b/src/mono/netcore/init-tools.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+# always ignore system dotnet
+export use_installed_dotnet_cli=false
+. "../../../eng/common/tools.sh"
+InitializeDotNetCli true
+which dotnet
\ No newline at end of file
diff --git a/src/mono/netcore/sample/HelloWorld/HelloWorld.csproj b/src/mono/netcore/sample/HelloWorld/HelloWorld.csproj
index af90cfdddfb5..521875cd647f 100644
--- a/src/mono/netcore/sample/HelloWorld/HelloWorld.csproj
+++ b/src/mono/netcore/sample/HelloWorld/HelloWorld.csproj
@@ -3,7 +3,7 @@
Exe
bin
- $(NetCoreAppCurrent);netcoreapp3.1
+ $(NetCoreAppCurrent)
full