diff --git a/src/tests/Common/CLRTest.CrossGen.targets b/src/tests/Common/CLRTest.CrossGen.targets
index 6075c74b6d297c..94c6c403f8411f 100644
--- a/src/tests/Common/CLRTest.CrossGen.targets
+++ b/src/tests/Common/CLRTest.CrossGen.targets
@@ -82,16 +82,6 @@ if [ ! -z ${RunCrossGen2+x} ]%3B then
__ResponseFile="$__OutputFile.rsp"
rm $__ResponseFile
- # Suppress the GC stress COMPlus for the duration of Crossgen2 execution
- local gcStressModeToRestore=$COMPlus_GCStress;
- local heapVerifyModeToRestore=$COMPlus_HeapVerify;
- local readyToRunModeToRestore=$COMPlus_ReadyToRun;
- local gcstandaloneModeToRestore=$COMPlus_GCName;
- unset COMPlus_GCStress
- unset COMPlus_HeapVerify
- unset COMPlus_ReadyToRun
- unset COMPlus_GCName
-
__Command=$_DebuggerFullPath
# Tests run locally need __TestDotNetCmd (set by runtest.py) or a compatible 5.0 dotnet runtime in the path
if [ ! -z ${__TestDotNetCmd+x} ] %3B then
@@ -115,14 +105,15 @@ if [ ! -z ${RunCrossGen2+x} ]%3B then
echo "Response file: $__ResponseFile"
cat $__ResponseFile
+
+ # Suppress some COMPlus variables for the duration of Crossgen2 execution
+ export -n COMPlus_GCName COMPlus_GCStress COMPlus_HeapVerify COMPlus_ReadyToRun
+
echo "Running CrossGen2: $__Command"
$__Command
__cg2ExitCode=$?
- export COMPlus_GCName=$gcstandaloneModeToRestore
- export COMPlus_GCStress=$gcStressModeToRestore
- export COMPlus_HeapVerify=$heapVerifyModeToRestore
- export COMPlus_ReadyToRun=$readyToRunModeToRestore
+ export COMPlus_GCName COMPlus_GCStress COMPlus_HeapVerify COMPlus_ReadyToRun
}
if [ ! -z ${CompositeBuildMode+x} ]%3B then
@@ -220,16 +211,6 @@ if defined RunCrossGen2 (
set __ResponseFile=!__OutputFile!.rsp
del /Q !__ResponseFile!
- REM Suppress GC stress mode for the duration of Crossgen2 execution
- set __gcStressModeToRestore=!COMPlus_GCStress!
- set COMPlus_GCStress=
- set __heapVerifyModeToRestore=!COMPlus_HeapVerify!
- set COMPlus_HeapVerify=
- set __readyToRunModeToRestore=!COMPlus_ReadyToRun!
- set COMPlus_ReadyToRun=
- set __gcStandaloneModeToRestore=!COMPlus_GCName!
- set COMPlus_GCName=
-
set __Command=!_DebuggerFullPath!
REM Tests run locally need __TestDotNetCmd (set by runtest.py) or a compatible 5.0 dotnet runtime in the path
if defined __TestDotNetCmd (
@@ -257,14 +238,17 @@ if defined RunCrossGen2 (
echo Response file: !__ResponseFile!
type !__ResponseFile!
+ REM Suppress some COMPlus variables for the duration of Crossgen2 execution
+ setlocal
+ set "COMPlus_GCName="
+ set "COMPlus_GCStress="
+ set "COMPlus_HeapVerify="
+ set "COMPlus_ReadyToRun="
+
echo "!__Command!"
call !__Command!
+ endlocal
set CrossGen2Status=!ERRORLEVEL!
- set COMPlus_GCStress=!__gcStressModeToRestore!
- set COMPlus_HeapVerify=!__heapVerifyModeToRestore!
- set COMPlus_ReadyToRun=!__readyToRunModeToRestore!
- set COMPlus_GCName=!__gcStandaloneModeToRestore!
-
Exit /b 0
:DoneCrossgen2Operations
diff --git a/src/tests/baseservices/TieredCompilation/BasicTestWithMcj.csproj b/src/tests/baseservices/TieredCompilation/BasicTestWithMcj.csproj
index a25cf031089641..3ef80d97d4050d 100644
--- a/src/tests/baseservices/TieredCompilation/BasicTestWithMcj.csproj
+++ b/src/tests/baseservices/TieredCompilation/BasicTestWithMcj.csproj
@@ -4,8 +4,6 @@
true
true
0
-
- true
true
@@ -24,13 +22,29 @@
diff --git a/src/tests/readytorun/coreroot_determinism/coreroot_determinism.csproj b/src/tests/readytorun/coreroot_determinism/coreroot_determinism.csproj
index 9b0cf13bd4cb69..72ecd6079b7c0f 100644
--- a/src/tests/readytorun/coreroot_determinism/coreroot_determinism.csproj
+++ b/src/tests/readytorun/coreroot_determinism/coreroot_determinism.csproj
@@ -4,8 +4,6 @@
BuildAndRun
0
true
-
- true
false
2.0
diff --git a/src/tests/readytorun/determinism/crossgen2determinism.csproj b/src/tests/readytorun/determinism/crossgen2determinism.csproj
index db389a1be5cf4c..029cb2aa809f69 100644
--- a/src/tests/readytorun/determinism/crossgen2determinism.csproj
+++ b/src/tests/readytorun/determinism/crossgen2determinism.csproj
@@ -4,7 +4,7 @@
BuildAndRun
0
true
-
+
true
false
diff --git a/src/tests/readytorun/multifolder/multifolder.csproj b/src/tests/readytorun/multifolder/multifolder.csproj
index 4013343db51dae..7011612ab6dc75 100644
--- a/src/tests/readytorun/multifolder/multifolder.csproj
+++ b/src/tests/readytorun/multifolder/multifolder.csproj
@@ -2,7 +2,8 @@
exe
BuildAndRun
- true
+
+ true
false
0
diff --git a/src/tests/readytorun/tests/mainv1.csproj b/src/tests/readytorun/tests/mainv1.csproj
index 032c89953606e9..5e51ca941e6572 100644
--- a/src/tests/readytorun/tests/mainv1.csproj
+++ b/src/tests/readytorun/tests/mainv1.csproj
@@ -3,8 +3,6 @@
exe
BuildAndRun
false
-
- true
@@ -19,6 +17,14 @@
diff --git a/src/tests/readytorun/tests/mainv2.csproj b/src/tests/readytorun/tests/mainv2.csproj
index a60c79cf464dab..3d9794e7c93591 100644
--- a/src/tests/readytorun/tests/mainv2.csproj
+++ b/src/tests/readytorun/tests/mainv2.csproj
@@ -3,8 +3,6 @@
exe
BuildAndRun
false
-
- true
@@ -17,6 +15,14 @@