:: remove trailing slash
if %__ProjectDir:~-1%==\ set "__ProjectDir=%__ProjectDir:~0,-1%"
set "__RepoRootDir=%__ProjectDir%\..\.."
+for %%i in ("%__RepoRootDir%") do SET "__RepoRootDir=%%~fi"
set "__TestDir=%__ProjectDir%\tests"
set "__ProjectFilesDir=%__TestDir%"
if "%__TargetsWindows%" == "1" (
echo %__MsgPrefix%Running crossgen on framework assemblies in CORE_ROOT: %CORE_ROOT%
call :PrecompileFX
+ if ERRORLEVEL 1 (
+ echo %__ErrMsgPrefix%%__MsgPrefix%Error: crossgen precompilation of framework assemblies failed
+ exit /b 1
+ )
) else (
echo "%__MsgPrefix%Crossgen only supported on Windows, for now"
)
if "%__BuildArch%" == "x64" (
echo %__MsgPrefix%Running crossgen2 on framework assemblies in CORE_ROOT: %CORE_ROOT%
call :PrecompileFX
+ if ERRORLEVEL 1 (
+ echo %__ErrMsgPrefix%%__MsgPrefix%Error: crossgen2 precompilation of framework assemblies failed
+ exit /b 1
+ )
) else (
echo "%__MsgPrefix%Crossgen2 only supported on x64, for now"
)
exit /b 1
:PrecompileFX
-for %%F in (%CORE_ROOT%\*.dll) do call :PrecompileAssembly "%%F" %%~nF%%~xF
-exit /b 0
+set __TotalPrecompiled=0
+set __FailedToPrecompile=0
+set __FailedAssemblies=
+for %%F in ("%CORE_ROOT%\System.*.dll";"%CORE_ROOT%\Microsoft.*.dll") do (
+ if not "%%~nxF"=="Microsoft.CodeAnalysis.VisualBasic.dll" (
+ if not "%%~nxF"=="Microsoft.CodeAnalysis.CSharp.dll" (
+ if not "%%~nxF"=="Microsoft.CodeAnalysis.dll" (
+ if not "%%~nxF"=="System.Runtime.WindowsRuntime.dll" (
+ call :PrecompileAssembly "%%F" %%~nxF __TotalPrecompiled __FailedToPrecompile __FailedAssemblies
+ echo Processed: !__TotalPrecompiled!, failed !__FailedToPrecompile!
+ )))))
+)
+
+if !__FailedToPrecompile! NEQ 0 (
+ echo Failed assemblies:
+ FOR %%G IN (!__FailedAssemblies!) do echo %%G
+)
+
+exit /b !__FailedToPrecompile!
REM Compile the managed assemblies in Core_ROOT before running the tests
:PrecompileAssembly
set AssemblyPath=%1
set AssemblyName=%2
-REM Don't precompile xunit.* files
-echo "%AssemblyName%" | findstr /b "xunit." >nul && (
- exit /b 0
-)
-
-REM Skip the Win32 API dll's
-if /i "%AssemblyName:~0,4%"=="api-" exit /b 0
-
set __CrossgenExe="%CORE_ROOT%\crossgen.exe"
if /i "%__BuildArch%" == "arm" ( set __CrossgenExe="%CORE_ROOT%\x86\crossgen.exe" )
if /i "%__BuildArch%" == "arm64" ( set __CrossgenExe="%CORE_ROOT%\x64\crossgen.exe" )
if defined __DoCrossgen (
set __CrossgenCmd=!__CrossgenExe! /Platform_Assemblies_Paths "!CORE_ROOT!" /in !AssemblyPath! /out !__CrossgenOutputFile!
) else (
- set __CrossgenCmd=!__CrossgenExe! -r:"!CORE_ROOT!\System.*.dll" -r:"!CORE_ROOT!\Microsoft.*.dll" -r:"!CORE_ROOT!\mscorlib.dll" -O --inputbubble --out:!__CrossgenOutputFile! !AssemblyPath!
+ set __CrossgenCmd=!__CrossgenExe! -r:"!CORE_ROOT!\System.*.dll" -r:"!CORE_ROOT!\Microsoft.*.dll" -r:"!CORE_ROOT!\mscorlib.dll" -r:"!CORE_ROOT!\netstandard.dll" -O --inputbubble --out:!__CrossgenOutputFile! !AssemblyPath!
)
echo %__CrossgenCmd%
%__CrossgenCmd%
set /a __exitCode = !errorlevel!
+set /a "%~3+=1"
+
if "%__exitCode%" == "-2146230517" (
echo %AssemblyPath% is not a managed assembly.
exit /b 0
)
if %__exitCode% neq 0 (
- echo Unable to precompile %AssemblyPath%, Exit Code is %__exitCode%
+ echo Unable to precompile %AssemblyPath%, exit code is %__exitCode%
+ set /a "%~4+=1"
+ set "%~5=!%~5!,!AssemblyName!"
exit /b 0
)
mkdir ${outputDir}
- skipCrossGenFiles+=('System.Private.CoreLib.dll')
- skipCrossGenFiles+=('System.Runtime.Serialization.Formatters.dll')
skipCrossGenFiles+=('Microsoft.CodeAnalysis.CSharp.dll')
skipCrossGenFiles+=('Microsoft.CodeAnalysis.dll')
skipCrossGenFiles+=('Microsoft.CodeAnalysis.VisualBasic.dll')
- skipCrossGenFiles+=('CommandLine.dll')
- for reference in ${overlayDir}/*.dll
- do
+ for reference in ${overlayDir}/*.dll; do
crossgen2References+=" -r:${reference}"
done
fi
echo "${__MsgPrefix}Running ${compilerName} on framework assemblies in CORE_ROOT: '${CORE_ROOT}'"
- filesToPrecompile=$(find -L $overlayDir -maxdepth 1 -iname \*.dll -not -iname \*.ni.dll -not -iname \*-ms-win-\* -not -iname xunit.\* -type f)
- for fileToPrecompile in ${filesToPrecompile}
- do
+ local totalPrecompiled=0
+ local failedToPrecompile=0
+ declare -a failedAssemblies
+
+ filesToPrecompile=$(find -L $overlayDir -maxdepth 1 -iname Microsoft.\*.dll -o -iname System.\*.dll -type f)
+ for fileToPrecompile in ${filesToPrecompile}; do
local filename=${fileToPrecompile}
if is_skip_crossgen_test "$(basename $filename)"; then
- continue
+ continue
fi
echo Precompiling $filename
if grep -q -e '0x80131018' $filename.stderr; then
printf "\n\t$filename is not a managed assembly.\n\n"
else
- echo Unable to precompile $filename.
+ echo Unable to precompile $filename, exit code is $exitCode.
cat $filename.stdout
cat $filename.stderr
- exit $exitCode
+ failedAssemblies+=($(basename -- "$filename"))
+ failedToPrecompile=$((failedToPrecompile+1))
fi
else
rm $filename.{stdout,stderr}
fi
+
+ totalPrecompiled=$((totalPrecompiled+1))
+ echo Processed: $totalPrecompiled, failed $failedToPrecompile
done
if [[ $__DoCrossgen2 != 0 ]]; then
mv -f ${outputDir}/* ${overlayDir}/
rm -r ${outputDir}
fi
+
+ if [[ $failedToPrecompile != 0 ]]; then
+ echo Failed assemblies:
+ for assembly in "${failedAssemblies[@]}"; do
+ echo " $assembly"
+ done
+
+ exit 1
+ fi
}
declare -a skipCrossGenFiles
echo "To run single test use the following command:"
echo " bash ${__TestBinDir}/__TEST_PATH__/__TEST_NAME__.sh -coreroot=${CORE_ROOT}"
fi
-