The use of goto :eof in numerous places in the build and test scripts is problematic. If preceded by an echo or other command, it will overwrite the exit code and the script may return incorrectly. This was happening for buildtest, masking a recent ycompilation error in one of the tests.
Change all of the goto :eof's to exit /b.
if defined VS%__VSProductVersion%COMNTOOLS goto CheckVSExistence
echo Visual Studio 2013 Community (free) is a pre-requisite to build this repository.
echo See: https://github.com/dotnet/coreclr/wiki/Developer-Guide#prerequisites
-goto :eof
+exit /b 1
:CheckVSExistence
:: Does VS 2013 or VS 2015 really exist?
if exist "!VS%__VSProductVersion%COMNTOOLS!\..\IDE\devenv.exe" goto CheckMSBuild
echo Visual Studio 2013 Community (free) is a pre-requisite to build this repository.
echo See: https://github.com/dotnet/coreclr/wiki/Developer-Guide#prerequisites
-goto :eof
+exit /b 1
:CheckMSBuild
:: Note: We've disabled node reuse because it causes file locking issues.
echo Visual Studio 2013 Express does not include the DIA SDK. ^
You need Visual Studio 2013 Community (free).
echo See: https://github.com/dotnet/coreclr/wiki/Developer-Guide#prerequisites
-goto :eof
+exit /b 1
:GenVSSolution
:: Regenerate the VS solution
:BuildComponents
if exist "%__IntermediatesDir%\install.vcxproj" goto BuildCoreCLR
echo Failed to generate native component build project!
-goto :eof
+exit /b 1
REM Build CoreCLR
:BuildCoreCLR
%_msbuildexe% "%__IntermediatesDir%\install.vcxproj" %__MSBCleanBuildArgs% /nologo /maxcpucount /nodeReuse:false /p:Configuration=%__BuildType% /p:Platform=%__BuildArch% /fileloggerparameters:Verbosity=diag;LogFile="%__CoreCLRBuildLog%"
IF NOT ERRORLEVEL 1 goto PerformMScorlibBuild
echo Native component build failed. Refer !__CoreCLRBuildLog! for details.
-goto :eof
+exit /b 1
:PerformMScorlibBuild
REM endlocal to rid us of environment changes from vcvarsall.bat
set "__MScorlibBuildLog=%__LogsDir%\MScorlib_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
%_msbuildexe% "%__ProjectFilesDir%\build.proj" %__MSBCleanBuildArgs% /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%__MScorlibBuildLog%" /p:OS=%__BuildOS% %__AdditionalMSBuildArgs%
IF NOT ERRORLEVEL 1 (
- if defined __MscorlibOnly goto :eof
+ if defined __MscorlibOnly exit /b 0
goto CrossGenMscorlib
)
echo MScorlib build failed. Refer !__MScorlibBuildLog! for details.
-goto :eof
+exit /b 1
:CrossGenMscorlib
echo Generating native image of mscorlib for %__BuildOS%.%__BuildArch%.%__BuildType%
)
echo CrossGen mscorlib failed. Refer !__CrossGenMScorlibLog! for details.
-goto :eof
+exit /b 1
:PerformTestBuild
echo.
call tests\buildtest.cmd
IF NOT ERRORLEVEL 1 goto SuccessfulBuild
echo Test binaries build failed. Refer !__MScorlibBuildLog! for details.
-goto :eof
+exit /b 1
:SuccessfulBuild
::Build complete
echo.
echo Product binaries are available at !__BinDir!
echo Test binaries are available at !__TestBinDir!
-goto :eof
+exit /b 0
:Usage
echo.
:: Check presence of VS
if defined VS%__VSProductVersion%COMNTOOLS goto CheckVSExistence
echo Installation of VS 2013 is a pre-requisite to build this repository.
-goto :eof
+exit /b 1
:CheckVSExistence
:: Does VS 2013 or VS 2015 really exist?
if exist "!VS%__VSProductVersion%COMNTOOLS!\..\IDE\devenv.exe" goto CheckMSBuild
echo Installation of VS 2013 is a pre-requisite to build this repository.
-goto :eof
+exit /b 1
:CheckMSBuild
if /i "%__VSVersion%" =="vs2015" goto MSBuild14
This is due to bug in VS Intaller. It does not install DIA SDK at "%VSINSTALLDIR%" but rather ^
at VS install location of previous version. Workaround is to copy DIA SDK folder from VS install location ^
of previous version to "%VSINSTALLDIR%" and then resume build.
-goto :eof
+exit /b 1
:GenVSSolution
:: Regenerate the VS solution
:BuildComponents
if exist "%__NativeTestIntermediatesDir%\install.vcxproj" goto BuildTestNativeComponents
echo Failed to generate test native component build project!
-goto :eof
+exit /b 1
REM Build CoreCLR
:BuildTestNativeComponents
%_msbuildexe% "%__NativeTestIntermediatesDir%\install.vcxproj" %__MSBCleanBuildArgs% /nologo /maxcpucount /nodeReuse:false /p:Configuration=%__BuildType% /p:Platform=%__BuildArch% /fileloggerparameters:Verbosity=diag;LogFile="%__TestNativeBuildLog%"
IF NOT ERRORLEVEL 1 goto PerformManagedTestBuild
echo Native component build failed. Refer !__TestNativeBuildLog! for details.
-goto :eof
+exit /b 1
:PerformManagedTestBuild
REM endlocal to rid us of environment changes from vcvarsall.bat
set _buildpostfix=
set _buildappend=
call :build %1
-
-goto :eof
+exit /b %ERRORLEVEL%
:build
%_buildprefix% %_msbuildexe% "%__ProjectFilesDir%\build.proj" %__MSBCleanBuildArgs% /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%__TestManagedBuildLog%";Append %* %_buildpostfix%
IF ERRORLEVEL 1 echo Test build failed. Refer !__TestManagedBuildLog! for details && exit /b 1
+exit /b 0
-endlocal
-
-
-
-goto :eof
:Usage
echo.
echo Usage:
:: Check presence of VS
if defined VS%__VSProductVersion%COMNTOOLS goto CheckMSbuild
echo Installation of VS 2013 is a pre-requisite to build this repository.
-goto :eof
+exit /b 1
:CheckMSBuild
if /i "%__VSVersion%" =="vs2015" goto MSBuild14
set _buildpostfix=
set _buildappend=
call :PerformXunitWrapperBuild
+IF ERRORLEVEL 1 (
+ echo XunitWrapperBuild build failed. Refer %__XunitWrapperBuildLog% for details.
+ exit /b 1
+)
-IF %BUILDERRORLEVEL% NEQ 0 echo XunitWrapperBuild build failed. Refer %__XunitWrapperBuildLog% for details. && exit /b %BUILDERRORLEVEL%
-
-call :preptests
-goto :eof
-
-:PerformXunitWrapperBuild
-
-%_buildprefix% %_msbuildexe% "%__ProjectFilesDir%runtest.proj" /p:NoRun=true /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%__XunitWrapperBuildLog%";Append %1 %_buildappend%%_buildpostfix%
-
-set BUILDERRORLEVEL=%ERRORLEVEL%
-
-goto :eof
-
-:preptests
:: Log build command line
set _buildprefix=echo
set _buildpostfix=^> "%__TestRunBuildLog%"
set _buildappend=^>
-call :runtests
+call :runtests
:: Build
set _buildprefix=
md %Core_Root%
xcopy /s %__BinDir% %Core_Root%
call :runtests
-
-IF %BUILDERRORLEVEL% NEQ 0 (
+if ERRORLEVEL 1 (
echo Test Run failed. Refer to the following"
echo Msbuild log: %__TestRunBuildLog%
echo Html report: %__TestRunHtmlLog%
- exit /b %BUILDERRORLEVEL%
+ exit /b 1
)
-goto :eof
:runtests
%_buildprefix% %_msbuildexe% "%__ProjectFilesDir%runtest.proj" /p:NoBuild=true /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%__TestRunBuildLog%";Append %1 %_buildpostfix%
+exit /b %ERRORLEVEL%
-set BUILDERRORLEVEL=%ERRORLEVEL%
-goto :eof
+:PerformXunitWrapperBuild
+
+%_buildprefix% %_msbuildexe% "%__ProjectFilesDir%runtest.proj" /p:NoRun=true /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%__XunitWrapperBuildLog%";Append %1 %_buildappend%%_buildpostfix%
+exit /b %ERRORLEVEL%
:Usage
echo.