From 27923d44ab68644671791a4790b8113eb9df611e Mon Sep 17 00:00:00 2001 From: "Brett V. Forsgren" Date: Wed, 22 Nov 2017 16:33:28 -0800 Subject: [PATCH] use ildasm.exe from a NuGet package (#3995) --- build.cmd | 23 ++++++++++------------- tests/fsharp/packages.config | 2 ++ tests/fsharp/test-framework.fs | 13 +++++++++---- tests/fsharp/tests.fs | 6 +++--- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/build.cmd b/build.cmd index 4a45c333d..88c6be98f 100644 --- a/build.cmd +++ b/build.cmd @@ -589,6 +589,15 @@ if "%RestorePackages%" == "true" ( %_nugetexe% restore setup\packages.config !_nugetoptions! @if ERRORLEVEL 1 echo Error: Nuget restore failed && goto :failure ) + + set restore_fsharp_suite=0 + if "%TEST_NET40_FSHARP_SUITE%" == "1" set restore_fsharp_suite=1 + if "%TEST_CORECLR_FSHARP_SUITE%" == "1" set restore_fsharp_suite=1 + + if "!restore_fsharp_suite!" == "1" ( + %_nugetexe% restore tests\fsharp\packages.config !_nugetoptions! + @if ERRORLEVEL 1 echo Error: Nuget restore failed && goto :failure + ) ) if "%BUILD_PROTO_WITH_CORECLR_LKG%" == "1" ( @@ -689,16 +698,6 @@ if not "%OSARCH%"=="x86" set REGEXE32BIT=%WINDIR%\syswow64\reg.exe echo SDK environment vars from Registry echo ================================== -::See https://stackoverflow.com/a/17113667/111575 on 2^>NUL for suppressing the error "ERROR: The system was unable to find the specified registry key or value." from reg.exe, this fixes #3619 - FOR /F "tokens=2* delims= " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\WOW6432Node\Microsoft\Microsoft SDKs\NETFXSDK\4.6.2\WinSDK-NetFx40Tools" /v InstallationFolder 2^>NUL') DO SET WINSDKNETFXTOOLS=%%B -if "%WINSDKNETFXTOOLS%"=="" FOR /F "tokens=2* delims= " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\WOW6432Node\Microsoft\Microsoft SDKs\NETFXSDK\4.6.1\WinSDK-NetFx40Tools" /v InstallationFolder 2^>NUL') DO SET WINSDKNETFXTOOLS=%%B -if "%WINSDKNETFXTOOLS%"=="" FOR /F "tokens=2* delims= " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\Microsoft\Microsoft SDKs\NETFXSDK\4.6\WinSDK-NetFx40Tools" /v InstallationFolder 2^>NUL') DO SET WINSDKNETFXTOOLS=%%B -if "%WINSDKNETFXTOOLS%"=="" FOR /F "tokens=2* delims= " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\Microsoft\Microsoft SDKs\Windows\v8.1A\WinSDK-NetFx40Tools" /v InstallationFolder 2^>NUL') DO SET WINSDKNETFXTOOLS=%%B -if "%WINSDKNETFXTOOLS%"=="" FOR /F "tokens=2* delims= " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\Microsoft\Microsoft SDKs\Windows\v8.0A\WinSDK-NetFx40Tools" /v InstallationFolder 2^>NUL') DO SET WINSDKNETFXTOOLS=%%B -if "%WINSDKNETFXTOOLS%"=="" FOR /F "tokens=2* delims= " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\Microsoft\Microsoft SDKs\Windows\v7.1\WinSDK-NetFx40Tools" /v InstallationFolder 2^>NUL') DO SET WINSDKNETFXTOOLS=%%B -if "%WINSDKNETFXTOOLS%"=="" FOR /F "tokens=2* delims= " %%A IN ('%REGEXE32BIT% QUERY "HKLM\Software\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFx40Tools" /v InstallationFolder 2^>NUL') DO SET WINSDKNETFXTOOLS=%%B - -set PATH=%PATH%;%WINSDKNETFXTOOLS% for /d %%i in (%WINDIR%\Microsoft.NET\Framework\v4.0.?????) do set CORDIR=%%i set PATH=%PATH%;%CORDIR% @@ -706,7 +705,6 @@ set REGEXE32BIT=reg.exe IF NOT DEFINED SNEXE32 IF EXIST "%WINSDKNETFXTOOLS%\sn.exe" set SNEXE32=%WINSDKNETFXTOOLS%sn.exe IF NOT DEFINED SNEXE64 IF EXIST "%WINSDKNETFXTOOLS%x64\sn.exe" set SNEXE64=%WINSDKNETFXTOOLS%x64\sn.exe -IF NOT DEFINED ildasm IF EXIST "%WINSDKNETFXTOOLS%\ildasm.exe" set ildasm=%WINSDKNETFXTOOLS%ildasm.exe echo. echo SDK environment vars @@ -714,7 +712,6 @@ echo ======================= echo WINSDKNETFXTOOLS: %WINSDKNETFXTOOLS% echo SNEXE32: %SNEXE32% echo SNEXE64: %SNEXE64% -echo ILDASM: %ILDASM% echo if "%TEST_NET40_COMPILERUNIT_SUITE%" == "0" if "%TEST_NET40_COREUNIT_SUITE%" == "0" if "%TEST_CORECLR_COREUNIT_SUITE%" == "0" if "%TEST_VS_IDEUNIT_SUITE%" == "0" if "%TEST_NET40_FSHARP_SUITE%" == "0" if "%TEST_NET40_FSHARPQA_SUITE%" == "0" goto :success @@ -915,7 +912,7 @@ if "%TEST_CORECLR_FSHARP_SUITE%" == "1" ( set OUTPUTFILE= set ERRORFILE= set XMLFILE=!RESULTSDIR!\test-coreclr-fsharp-results.xml - echo "%_dotnetcliexe%" "%~dp0tests\testbin\!BUILD_CONFIG!\coreclr\FSharp.Core.Unittests\FSharp.Core.Unittests.dll" !WHERE_ARG_NUNIT! + echo "%_dotnetcliexe%" "%~dp0tests\testbin\!BUILD_CONFIG!\coreclr\FSharp.Tests.FSharpSuite.DrivingCoreCLR\FSharp.Tests.FSharpSuite.DrivingCoreCLR.dll" !WHERE_ARG_NUNIT! "%_dotnetcliexe%" "%~dp0tests\testbin\!BUILD_CONFIG!\coreclr\FSharp.Tests.FSharpSuite.DrivingCoreCLR\FSharp.Tests.FSharpSuite.DrivingCoreCLR.dll" !WHERE_ARG_NUNIT! if errorlevel 1 ( diff --git a/tests/fsharp/packages.config b/tests/fsharp/packages.config index 95311a04c..20a3b06b9 100644 --- a/tests/fsharp/packages.config +++ b/tests/fsharp/packages.config @@ -1,6 +1,8 @@  + + \ No newline at end of file diff --git a/tests/fsharp/test-framework.fs b/tests/fsharp/test-framework.fs index f96816f71..915f6ac37 100644 --- a/tests/fsharp/test-framework.fs +++ b/tests/fsharp/test-framework.fs @@ -167,28 +167,33 @@ let requireFile nm = let config configurationName envVars = - let SCRIPT_ROOT = __SOURCE_DIRECTORY__ + let SCRIPT_ROOT = __SOURCE_DIRECTORY__ + let packagesDir = SCRIPT_ROOT ++ ".." ++ ".." ++ "packages" let FSCBinPath = SCRIPT_ROOT ++ ".." ++ ".." ++ configurationName ++ "net40" ++ "bin" let csc_flags = "/nologo" let fsc_flags = "-r:System.Core.dll --nowarn:20 --define:COMPILED" let fsi_flags = "-r:System.Core.dll --nowarn:20 --define:INTERACTIVE --maxerrors:1 --abortonerror" let CORDIR, CORSDK = WindowsPlatform.clrPaths envVars let Is64BitOperatingSystem = WindowsPlatform.Is64BitOperatingSystem envVars + let architectureMoniker = if Is64BitOperatingSystem then "x64" else "x86" let CSC = requireFile (CORDIR ++ "csc.exe") - let ILDASM = requireFile (CORSDK ++ "ildasm.exe") + let ILDASM = requireFile (packagesDir ++ ("runtime.win-" + architectureMoniker + ".Microsoft.NETCore.ILDAsm.2.0.3") ++ "runtimes" ++ ("win-" + architectureMoniker) ++ "native" ++ "ildasm.exe") let PEVERIFY = requireFile (CORSDK ++ "peverify.exe") let FSI_FOR_SCRIPTS = match envVars |> Map.tryFind "_fsiexe" with | Some fsiexe when (not (String.IsNullOrWhiteSpace fsiexe)) -> requireFile (SCRIPT_ROOT ++ ".." ++ ".." ++ (fsiexe.Trim([| '\"' |]))) | _ -> // build.cmd sets that var, if it is not set, we are probably called directly from visual studio or the nunit console runner. - let packagesDir = SCRIPT_ROOT ++ ".." ++ ".." ++ @"packages" let fsharpCompilerTools = Directory.GetDirectories(packagesDir, "FSharp.Compiler.Tools.*") match fsharpCompilerTools with | [||] -> failwithf "Could not find any 'FSharp.Compiler.Tools' inside '%s'" packagesDir | [| dir |] -> Path.Combine(dir, "tools", "fsi.exe") | _ -> failwithf "Found more than one 'FSharp.Compiler.Tools' inside '%s', please clean up." packagesDir - let dotNetExe = SCRIPT_ROOT ++ ".." ++ ".." ++ "Tools" ++ "dotnetcli" ++ "dotnet.exe" + let toolsDir = SCRIPT_ROOT ++ ".." ++ ".." ++ "Tools" + let dotNetExe = toolsDir ++ "dotnetcli" ++ "dotnet.exe" + // ildasm requires coreclr.dll to run which has already been restored to the tools directory + let coreclrSource = toolsDir ++ "dotnet20" ++ "shared" ++ "Microsoft.NETCore.App" ++ "2.0.0" ++ "coreclr.dll" + File.Copy(coreclrSource, Path.GetDirectoryName(ILDASM) ++ "coreclr.dll", overwrite=true) #if !FSHARP_SUITE_DRIVES_CORECLR_TESTS let FSI = requireFile (FSCBinPath ++ "fsi.exe") diff --git a/tests/fsharp/tests.fs b/tests/fsharp/tests.fs index 12403565f..4a4d35de5 100644 --- a/tests/fsharp/tests.fs +++ b/tests/fsharp/tests.fs @@ -1621,9 +1621,9 @@ module OptimizationTests = fsc cfg "%s --optimize -o:test--optimize.exe -g -r:lib--optimize.dll -r:lib3--optimize.dll" cfg.fsc_flags ["test.fs "] - ildasm cfg "/nobar /out=test.il" "test.exe" + ildasm cfg "/out=test.il" "test.exe" - ildasm cfg "/nobar /out=test--optimize.il" "test--optimize.exe" + ildasm cfg "/out=test--optimize.il" "test--optimize.exe" let ``test--optimize.il`` = File.ReadLines (getfullpath cfg "test--optimize.il") @@ -1646,7 +1646,7 @@ module OptimizationTests = let stats () = let cfg = testConfig "optimize/stats" - ildasm cfg "/nobar /out=FSharp.Core.il" cfg.FSCOREDLLPATH + ildasm cfg "/out=FSharp.Core.il" cfg.FSCOREDLLPATH let fscore = File.ReadLines(getfullpath cfg "FSharp.Core.il") |> Seq.toList -- GitLab