diff --git a/eng/Subsets.props b/eng/Subsets.props
index f2480616431b5..ce90e8748f887 100644
--- a/eng/Subsets.props
+++ b/eng/Subsets.props
@@ -336,7 +336,8 @@
$(CoreClrProjectRoot)tools\r2rdump\R2RDump.csproj;
$(CoreClrProjectRoot)tools\dotnet-pgo\dotnet-pgo.csproj;
$(CoreClrProjectRoot)tools\aot\ILCompiler\repro\repro.csproj;
- $(CoreClrProjectRoot)tools\r2rtest\R2RTest.csproj" Category="clr" Condition="'$(DotNetBuildFromSource)' != 'true'"/>
+ $(CoreClrProjectRoot)tools\r2rtest\R2RTest.csproj;
+ $(CoreClrProjectRoot)tools\AssemblyChecker\AssemblyChecker.csproj" Category="clr" Condition="'$(DotNetBuildFromSource)' != 'true'"/>
diff --git a/src/coreclr/tools/AssemblyChecker/AssemblyChecker.csproj b/src/coreclr/tools/AssemblyChecker/AssemblyChecker.csproj
new file mode 100644
index 0000000000000..821c47c95403c
--- /dev/null
+++ b/src/coreclr/tools/AssemblyChecker/AssemblyChecker.csproj
@@ -0,0 +1,16 @@
+
+
+ AssemblyChecker
+ Exe
+ $(NetCoreAppToolCurrent)
+ AnyCPU
+ false
+ true
+ true
+ false
+ enable
+ enable
+ $(RuntimeBinDir)\AssemblyChecker
+ false
+
+
diff --git a/src/coreclr/tools/AssemblyChecker/Program.cs b/src/coreclr/tools/AssemblyChecker/Program.cs
new file mode 100644
index 0000000000000..69f86e050beb2
--- /dev/null
+++ b/src/coreclr/tools/AssemblyChecker/Program.cs
@@ -0,0 +1,117 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Text;
+using System.Diagnostics;
+using System.Reflection;
+using System.Reflection.Metadata;
+using System.Reflection.PortableExecutable;
+
+namespace AssemblyChecker
+{
+ ///
+ /// This is a simple console application that is designed to answer True or False
+ /// questions about whether a given file is a managed assembly or not.
+ /// You can also ask whether or not the assembly is debuggable.
+ /// Return code of 0 indicates the file is a managed assembly.
+ /// Return code of 1 indicates the file is not a managed assembly. No errors will be printed for this one.
+ ///
+ public class Program
+ {
+ private const string HelpText = @"
+Usage:
+ : Check if the file-path is a managed assembly.
+ --is-debug : Check if the file-path is a managed assembly that is built with debuggability.
+ --is-exe : Check if the file-path is a managed assembly that is an executable.
+";
+
+ static bool IsAssembly(string path)
+ {
+ using var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
+
+ // Try to read CLI metadata from the PE file.
+ using var peReader = new PEReader(fs);
+
+ if (!peReader.HasMetadata)
+ {
+ return false; // File does not have CLI metadata.
+ }
+
+ // Check that file has an assembly manifest.
+ MetadataReader reader = peReader.GetMetadataReader();
+ return reader.IsAssembly;
+ }
+
+ static bool IsDebug(string path)
+ {
+ return
+ Assembly.LoadFrom(path)
+ .GetCustomAttributes(typeof(DebuggableAttribute), false)
+ .OfType().Any(x => x.IsJITOptimizerDisabled);
+ }
+
+ static bool IsExe(string path)
+ {
+ using var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
+
+ // Try to read CLI metadata from the PE file.
+ using var peReader = new PEReader(fs);
+
+ if (!peReader.HasMetadata)
+ {
+ return false; // File does not have CLI metadata.
+ }
+
+ return peReader.PEHeaders.IsExe;
+ }
+
+ static int Main(string[] args)
+ {
+ if (args.Length == 0)
+ {
+ Console.WriteLine(HelpText);
+ Console.Error.WriteLine("\nExpected assembly file-path.");
+ return 2;
+ }
+
+ // Help
+ if (args.Contains("-h"))
+ {
+ Console.WriteLine(HelpText);
+ return 0;
+ }
+
+ if (args.Length == 1)
+ {
+ return IsAssembly(args[0]) ? 0 : 1;
+ }
+
+ if (args.Length == 2)
+ {
+ switch (args[0])
+ {
+ case "--is-debug":
+ {
+ return IsDebug(args[1]) ? 0 : 1;
+ }
+
+ case "--is-exe":
+ {
+ return IsExe(args[1]) ? 0 : 1;
+ }
+
+ default:
+ {
+ Console.WriteLine(HelpText);
+ Console.Error.WriteLine("\nInvalid option.");
+ return 2;
+ }
+ }
+ }
+
+ Console.WriteLine(HelpText);
+ Console.Error.WriteLine("\nToo many arguments.");
+ return 2;
+ }
+ }
+}
diff --git a/src/tests/Common/CLRTest.Execute.Bash.targets b/src/tests/Common/CLRTest.Execute.Bash.targets
index ea33ed79bad9b..81a50db81cacc 100644
--- a/src/tests/Common/CLRTest.Execute.Bash.targets
+++ b/src/tests/Common/CLRTest.Execute.Bash.targets
@@ -381,8 +381,6 @@ else
LAUNCHER="$_DebuggerFullPath $_DebuggerArgsSeparator $(CLRTestRunFile)"
fi
-$(BashIlrtTestLaunchCmds)
-
if [ ! -z ${RunCrossGen2+x} ]%3B then
TakeLock
fi
@@ -412,8 +410,6 @@ else
LAUNCHER="$_DebuggerFullPath $_DebuggerArgsSeparator $(CLRTestRunFile)"
fi
-$(BashIlrtTestLaunchCmds)
-
if [ ! -z ${RunCrossGen2+x} ]%3B then
TakeLock
fi
diff --git a/src/tests/Common/CLRTest.Execute.Batch.targets b/src/tests/Common/CLRTest.Execute.Batch.targets
index 90ba71856b72e..f19c8987bbc6f 100644
--- a/src/tests/Common/CLRTest.Execute.Batch.targets
+++ b/src/tests/Common/CLRTest.Execute.Batch.targets
@@ -318,8 +318,6 @@ IF NOT "%CLRCustomTestLauncher%"=="" (
set LAUNCHER=%_DebuggerFullPath% $(CLRTestRunFile)
)
-$(BatchIlrtTestLaunchCmds)
-
if defined RunCrossGen2 (
call :TakeLock
)
diff --git a/src/tests/Common/CLRTest.Jit.targets b/src/tests/Common/CLRTest.Jit.targets
index 9748b6424f737..476595df0c8be 100644
--- a/src/tests/Common/CLRTest.Jit.targets
+++ b/src/tests/Common/CLRTest.Jit.targets
@@ -62,66 +62,16 @@ export RunningIlasmRoundTrip=
if [ -z "$DoLink" -a ! -z "$RunningIlasmRoundTrip" ];
then
- mkdir IL-RT
- cp $(InputAssemblyName) $(TargetAssemblyName)
- echo "$CORE_ROOT/ildasm" -raweh -unicode -out=$(DisassemblyName) $(TargetAssemblyName)
- "$CORE_ROOT/ildasm" -raweh -unicode -out=$(DisassemblyName) $(TargetAssemblyName)
+ python3 $(AssemblyName)_ilasmroundtrip.py
ERRORLEVEL=$?
if [ $ERRORLEVEL -ne 0 ]
then
- echo EXECUTION OF ILDASM - FAILED $ERRORLEVEL
- exit 1
- fi
- if [ ! -f "$(DisassemblyName)" ]
- then
- echo "EXECUTION OF ILDASM - FAILED $(DisassemblyName) is missing"
- exit 1
- fi
-
- ilasm_count=1
- while true
- do
- echo "$CORE_ROOT/ilasm" -output=$(InputAssemblyName) $(_IlasmSwitches) $(DisassemblyName)
- "$CORE_ROOT/ilasm" -output=$(InputAssemblyName) $(_IlasmSwitches) $(DisassemblyName)
- ERRORLEVEL=$?
- if [ $ERRORLEVEL -eq 0 ]
- then
- break
- fi
-
- echo EXECUTION $ilasm_count OF ILASM - FAILED with $ERRORLEVEL
-
- if [ $ilasm_count -eq 3 ]
- then
- break
- fi
-
- ((ilasm_count++))
- echo Trying again
- sleep 10
- done
-
- if [ $ERRORLEVEL -ne 0 ]
- then
+ echo ILASM ROUND-TRIP - FAILED $ERRORLEVEL
exit 1
fi
fi
]]>
-
-
@@ -144,54 +94,18 @@ set RunningIlasmRoundTrip=
REM IlasmRoundTrip Script
REM Disable Ilasm round-tripping for Linker tests.
REM Todo: Ilasm round-trip on linked binaries.
+
IF NOT DEFINED DoLink (
IF DEFINED RunningIlasmRoundTrip (
- mkdir IL-RT
- copy $(InputAssemblyName) $(TargetAssemblyName)
- ECHO %CORE_ROOT%\ildasm.exe /raweh /unicode /out=$(DisassemblyName) $(TargetAssemblyName)
- %CORE_ROOT%\ildasm.exe /raweh /unicode /out=$(DisassemblyName) $(TargetAssemblyName)
-
+ python $(AssemblyName)_ilasmroundtrip.py
IF NOT "!ERRORLEVEL!"=="0" (
- ECHO EXECUTION OF ILDASM - FAILED !ERRORLEVEL!
- Exit /b 1
- )
- IF NOT EXIST $(DisassemblyName) (
- ECHO EXECUTION OF ILDASM - FAILED $(DisassemblyName) is missing
- Exit /b 1
- )
-
- set ilasm_count=1
-:Try_ilasm
- ECHO %CORE_ROOT%\ilasm.exe /output=$(InputAssemblyName) $(_IlasmSwitches) $(DisassemblyName)
- %CORE_ROOT%\ilasm.exe /output=$(InputAssemblyName) $(_IlasmSwitches) $(DisassemblyName)
- IF NOT "!ERRORLEVEL!"=="0" (
- ECHO EXECUTION OF ILASM - Try !ilasm_count! FAILED with status !ERRORLEVEL!
- IF !ilasm_count! LEQ 3 (
- ECHO Trying again
- set /A ilasm_count=ilasm_count+1
- timeout /t 10 /nobreak
- goto :Try_ilasm
- )
- ECHO EXECUTION OF ILASM - FAILED
+ ECHO ILASM ROUND-TRIP - FAILED !ERRORLEVEL!
Exit /b 1
)
)
)
]]>
-
-
@@ -365,6 +279,109 @@ set DOTNET_JitPath=%CORE_ROOT%\superpmi-shim-collector.dll
+
+
+
+
+ $(AssemblyName).dll
+ IL-RT/$(AssemblyName).il
+ IL-RT/$(AssemblyName).dll
+ <_IlasmRoundTripScriptText>
+
+
+
+
+
+ True
+
+
diff --git a/src/tests/JIT/Methodical/fp/exgen/10w5d_cs_do.csproj b/src/tests/JIT/Methodical/fp/exgen/10w5d_cs_do.csproj
index 9eff379e0d455..d1e37c52b6423 100644
--- a/src/tests/JIT/Methodical/fp/exgen/10w5d_cs_do.csproj
+++ b/src/tests/JIT/Methodical/fp/exgen/10w5d_cs_do.csproj
@@ -3,6 +3,7 @@
true
+ true
Full
diff --git a/src/tests/JIT/Performance/CodeQuality/Bytemark/Bytemark.csproj b/src/tests/JIT/Performance/CodeQuality/Bytemark/Bytemark.csproj
index 03274a86e59cc..de85a9ce57835 100644
--- a/src/tests/JIT/Performance/CodeQuality/Bytemark/Bytemark.csproj
+++ b/src/tests/JIT/Performance/CodeQuality/Bytemark/Bytemark.csproj
@@ -3,6 +3,7 @@
true
true
+ true
$(NoWarn);xUnit1013
true
diff --git a/src/tests/JIT/Performance/CodeQuality/Roslyn/CscBench.csproj b/src/tests/JIT/Performance/CodeQuality/Roslyn/CscBench.csproj
index 37d4ba53a4c2b..045dc9053d1af 100644
--- a/src/tests/JIT/Performance/CodeQuality/Roslyn/CscBench.csproj
+++ b/src/tests/JIT/Performance/CodeQuality/Roslyn/CscBench.csproj
@@ -6,6 +6,7 @@
$(NoWarn);xUnit1013
true
true
+ true
pdbonly
diff --git a/src/tests/Loader/binding/tracing/BinderTracingTest.ResolutionFlow.csproj b/src/tests/Loader/binding/tracing/BinderTracingTest.ResolutionFlow.csproj
index 0bb68d9cb843d..07f4907e396c9 100644
--- a/src/tests/Loader/binding/tracing/BinderTracingTest.ResolutionFlow.csproj
+++ b/src/tests/Loader/binding/tracing/BinderTracingTest.ResolutionFlow.csproj
@@ -4,6 +4,8 @@
true
true
+ true
+ true
diff --git a/src/tests/ilverify/ILVerificationTests.csproj b/src/tests/ilverify/ILVerificationTests.csproj
index 3144da43d0c20..f9f7e7521ffaf 100644
--- a/src/tests/ilverify/ILVerificationTests.csproj
+++ b/src/tests/ilverify/ILVerificationTests.csproj
@@ -5,6 +5,8 @@
true
true
+ true
+ true