1 @if not defined __echo @echo off
4 set __ThisScriptShort=%0
5 set __ThisScriptFull=%~f0
6 set __ThisScriptPath=%~dp0
8 REM =========================================================================================
10 REM === Parse arguments
12 REM =========================================================================================
18 if "%1" == "" goto ArgsDone
20 if /i "%1" == "/?" goto Usage
21 if /i "%1" == "-?" goto Usage
22 if /i "%1" == "/h" goto Usage
23 if /i "%1" == "-h" goto Usage
24 if /i "%1" == "/help" goto Usage
25 if /i "%1" == "-help" goto Usage
27 if /i "%1" == "/arch" (set __Arch=%2&shift&shift&goto Arg_Loop)
28 if /i "%1" == "/outputdir" (set __OutputDir=%2&shift&shift&goto Arg_Loop)
30 echo Invalid command-line argument: %1
35 if not defined __OutputDir goto Usage
36 if not defined __Arch goto Usage
38 REM =========================================================================================
40 REM === Check if dotnet CLI and necessary directories exist
42 REM =========================================================================================
44 set __DotNetToolDir=%__ThisScriptPath%..\Tools
45 set __DotNetCmd=%__DotNetToolDir%\dotnetcli\dotnet.exe
46 set __PackageDir=%__ThisScriptPath%..\Packages
47 set __TmpDir=%Temp%\coreclr_gcstress_%RANDOM%
49 REM Check if donet cli exists
50 if not exist "%__DotNetToolDir%" (
51 echo Directory containing dotnet CLI does not exist: %__DotNetToolDir%
54 if not exist "%__DotNetCmd%" (
55 echo dotnet.exe does not exist: %__DotNetCmd%
59 REM Create directories needed
60 if not exist "%__PackageDir%" md "%__PackageDir%"
61 if not exist "%__OutputDir%" md "%__OutputDir%"
63 REM Check and create a temp directory
64 if exist "%__TmpDir%" (
65 rmdir /S /Q %__TmpDir%
70 set __JasonFilePath=%__TmpDir%\project.json
72 REM =========================================================================================
74 REM === Download packages
76 REM =========================================================================================
78 REM Write dependency information to project.json
81 "runtime.win7-%__Arch%.Microsoft.NETCore.CoreDisTools": "1.0.1-prerelease-00001" ^
83 "frameworks": { "dnxcore50": { } } ^
84 } > "%__JasonFilePath%"
86 echo Jason file: %__JasonFilePath%
87 type "%__JasonFilePath%"
89 REM Download the package
90 echo Downloading CoreDisTools package
91 set DOTNETCMD="%__DotNetCmd%" restore "%__JasonFilePath%" --source https://dotnet.myget.org/F/dotnet-core/ --packages "%__PackageDir%"
94 if errorlevel 1 goto Fail
96 REM Get downloaded dll path
97 echo Locating coredistools.dll
98 FOR /F "delims=" %%i IN ('dir %__PackageDir%\coredistools.dll /b/s ^| findstr /R "runtime.win[0-9]*-%__Arch%"') DO set __LibPath=%%i
99 echo CoreDisTools library path: %__LibPath%
100 if not exist "%__LibPath%" (
101 echo Failed to locate the downloaded library: %__LibPath%
105 REM Copy library to output directory
106 echo Copy library: %__LibPath% to %__OutputDir%
107 copy /y "%__LibPath%" "%__OutputDir%"
109 REM Delete temporary files
110 if exist "%__TmpDir%" (
111 rmdir /S /Q "%__TmpDir%"
117 if exist "%__TmpDir%" (
118 rmdir /S /Q "%__TmpDir%"
122 REM =========================================================================================
124 REM === Helper routines
126 REM =========================================================================================
130 echo Download coredistool for GC stress testing
133 echo %__ThisScriptShort% /arch ^<TargetArch^> /outputdir ^<coredistools_lib_install_path^>