summaryrefslogtreecommitdiff
path: root/tests/debugger_tests/ConfigFilesGenerators/GenerateConfig.cmd
blob: 635df958c6b0e2c2b6f37f5b9efefc1a4e1c3c9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
@echo off
setlocal EnableDelayedExpansion

:: Set the default arguments for script generation.
set __RuntimeRoot=`$(TestRoot)\Runtimes\Coreclr1
set __NugetCacheDir=`$(WorkingDir)\packages
set __CliPath=
set __ConfigFileName=Debugger.Tests.Config.txt
set __TemplateFileName=%~dp0\ConfigTemplate.txt

:Arg_Loop
if "%1" == "" goto ArgsDone
if /i "%1" == "/?" goto Usage

if /i "%1" == "rt"      (set "__RuntimeRoot=%2"&shift&shift&goto Arg_Loop)
if /i "%1" == "nc"      (set "__NugetCacheDir=%2"&shift&shift&goto Arg_Loop)
if /i "%1" == "cli"     (set "__CliPath=%2"&shift&shift&goto Arg_Loop)

echo Invalid commandline argument: %1
goto Usage

:ArgsDone

if not exist %__TemplateFileName% (
    echo Template file %__TemplateFileName% doesn't exist.
    exit /b 1
)

:: Delete previous config file.
if exist %__ConfigFileName% (
    echo Deleting current config file.
    del %__ConfigFileName%
)

:: powershell "Get-Content %__TemplateFileName% -replace (""##Insert_Runtime_Root##"", ""%__RuntimeRoot%"") | Output-File %__ConfigFileName% "
powershell "(Get-Content \"%__TemplateFileName%\")`"^
    "-replace \"##Insert_Runtime_Root##\", \"%__RuntimeRoot%\" `"^
    "|ForEach-Object{$_ -replace \"##Insert_Nuget_Cache_Root##\", \"%__NugetCacheDir%\"} `"^
    "|ForEach-Object{$_ -replace \"##Cli_Path##\", \"%__CliPath%\"} `"^
    "| Out-File \"%__ConfigFileName%\""

exit /b 0

:Usage
echo.
echo Usage:
echo %0 [rt ^<runtime_path^>] [nc ^<nuget_cache_path^>] [cli ^<cli_path^>] where:
echo.
echo ^<runtime_path^>: path to the runtime that you want to use for testing.
echo ^<nuget_cache_path^>: path to the nuget cache.
echo ^<cli_path^>: path to the cli tool.
exit /b 1
endlocal