22setlocal
33
44set INIT_TOOLS_LOG = %~dp0 init-tools.log
5- if [%PACKAGES_DIR% ]== [] set PACKAGES_DIR = %~dp0 packages\
5+ if [%PACKAGES_DIR% ]== [] set PACKAGES_DIR = %~dp0 packages
66if [%TOOLRUNTIME_DIR% ]== [] set TOOLRUNTIME_DIR = %~dp0 Tools
77set DOTNET_PATH = %TOOLRUNTIME_DIR% \dotnetcli\
88if [%DOTNET_CMD% ]== [] set DOTNET_CMD = %DOTNET_PATH% dotnet.exe
99if [%BUILDTOOLS_SOURCE% ]== [] set BUILDTOOLS_SOURCE = https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json
1010set /P BUILDTOOLS_VERSION = < " %~dp0 BuildToolsVersion.txt"
11- set BUILD_TOOLS_PATH = %PACKAGES_DIR% Microsoft.DotNet.BuildTools\%BUILDTOOLS_VERSION% \lib\
11+ set BUILD_TOOLS_PATH = %PACKAGES_DIR% \ Microsoft.DotNet.BuildTools\%BUILDTOOLS_VERSION% \lib
1212set INIT_TOOLS_RESTORE_PROJECT = %~dp0 init-tools.msbuild
1313set BUILD_TOOLS_SEMAPHORE_DIR = %TOOLRUNTIME_DIR% \%BUILDTOOLS_VERSION%
1414set BUILD_TOOLS_SEMAPHORE = %BUILD_TOOLS_SEMAPHORE_DIR% \init-tools.completed
1515
1616:: if force option is specified then clean the tool runtime and build tools package directory to force it to get recreated
1717if [%1 ]== [force] (
1818 if exist " %TOOLRUNTIME_DIR% " rmdir /S /Q " %TOOLRUNTIME_DIR% "
19- if exist " %PACKAGES_DIR% Microsoft.DotNet.BuildTools" rmdir /S /Q " %PACKAGES_DIR% Microsoft.DotNet.BuildTools"
19+ if exist " %PACKAGES_DIR% \ Microsoft.DotNet.BuildTools" rmdir /S /Q " %PACKAGES_DIR% \ Microsoft.DotNet.BuildTools"
2020)
2121
2222:: If semaphore exists do nothing
@@ -27,8 +27,6 @@ if exist "%BUILD_TOOLS_SEMAPHORE%" (
2727
2828if exist " %TOOLRUNTIME_DIR% " rmdir /S /Q " %TOOLRUNTIME_DIR% "
2929
30- if NOT exist " %BUILD_TOOLS_SEMAPHORE_DIR% " mkdir " %BUILD_TOOLS_SEMAPHORE_DIR% "
31-
3230if exist " %DotNetBuildToolsDir% " (
3331 echo Using tools from '%DotNetBuildToolsDir% '.
3432 mklink /j " %TOOLRUNTIME_DIR% " " %DotNetBuildToolsDir% "
@@ -39,6 +37,7 @@ if exist "%DotNetBuildToolsDir%" (
3937 )
4038
4139 echo Done initializing tools.
40+ if NOT exist " %BUILD_TOOLS_SEMAPHORE_DIR% " mkdir " %BUILD_TOOLS_SEMAPHORE_DIR% "
4241 echo Using tools from '%DotNetBuildToolsDir% '. > " %BUILD_TOOLS_SEMAPHORE% "
4342 exit /b 0
4443)
@@ -64,19 +63,18 @@ if NOT exist "%DOTNET_LOCAL_PATH%" (
6463
6564if exist " %BUILD_TOOLS_PATH% " goto :afterbuildtoolsrestore
6665echo Restoring BuildTools version %BUILDTOOLS_VERSION% ...
67- echo Running: " %DOTNET_CMD% " restore " %INIT_TOOLS_RESTORE_PROJECT% " --no-cache --packages %PACKAGES_DIR% --source " %BUILDTOOLS_SOURCE% " /p:BuildToolsPackageVersion=%BUILDTOOLS_VERSION% >> " %INIT_TOOLS_LOG% "
68- call " %DOTNET_CMD% " restore " %INIT_TOOLS_RESTORE_PROJECT% " --no-cache --packages %PACKAGES_DIR% --source " %BUILDTOOLS_SOURCE% " /p:BuildToolsPackageVersion=%BUILDTOOLS_VERSION% >> " %INIT_TOOLS_LOG% "
69- if NOT exist " %BUILD_TOOLS_PATH% init-tools.cmd" (
66+ echo Running: " %DOTNET_CMD% " restore " %INIT_TOOLS_RESTORE_PROJECT% " --no-cache --packages " %PACKAGES_DIR% " --source " %BUILDTOOLS_SOURCE% " /p:BuildToolsPackageVersion=%BUILDTOOLS_VERSION% /p:ToolsDir= %TOOLRUNTIME_DIR % >> " %INIT_TOOLS_LOG% "
67+ call " %DOTNET_CMD% " restore " %INIT_TOOLS_RESTORE_PROJECT% " --no-cache --packages " %PACKAGES_DIR% " --source " %BUILDTOOLS_SOURCE% " /p:BuildToolsPackageVersion=%BUILDTOOLS_VERSION% /p:ToolsDir= %TOOLRUNTIME_DIR % >> " %INIT_TOOLS_LOG% "
68+ if NOT exist " %BUILD_TOOLS_PATH% \ init-tools.cmd" (
7069 echo ERROR: Could not restore build tools correctly. 1 >& 2
7170 goto :error
7271)
7372
7473:afterbuildtoolsrestore
7574
76-
7775echo Initializing BuildTools...
78- echo Running: " %BUILD_TOOLS_PATH% init-tools.cmd" " %~dp0 " " %DOTNET_CMD% " " %TOOLRUNTIME_DIR% " >> " %INIT_TOOLS_LOG% "
79- call " %BUILD_TOOLS_PATH% init-tools.cmd" " %~dp0 " " %DOTNET_CMD% " " %TOOLRUNTIME_DIR% " >> " %INIT_TOOLS_LOG% "
76+ echo Running: " %BUILD_TOOLS_PATH% \ init-tools.cmd" " %~dp0 " " %DOTNET_CMD% " " %TOOLRUNTIME_DIR% " " %PACKAGES_DIR %" >> " %INIT_TOOLS_LOG% "
77+ call " %BUILD_TOOLS_PATH% \ init-tools.cmd" " %~dp0 " " %DOTNET_CMD% " " %TOOLRUNTIME_DIR% " " %PACKAGES_DIR %" >> " %INIT_TOOLS_LOG% "
8078set INIT_TOOLS_ERRORLEVEL = %ERRORLEVEL%
8179if not [%INIT_TOOLS_ERRORLEVEL% ]== [0] (
8280 echo ERROR: An error occured when trying to initialize the tools. 1 >& 2
@@ -85,10 +83,11 @@ if not [%INIT_TOOLS_ERRORLEVEL%]==[0] (
8583
8684:: Create semaphore file
8785echo Done initializing tools.
86+ if NOT exist " %BUILD_TOOLS_SEMAPHORE_DIR% " mkdir " %BUILD_TOOLS_SEMAPHORE_DIR% "
8887echo Init-Tools.cmd completed for BuildTools Version: %BUILDTOOLS_VERSION% > " %BUILD_TOOLS_SEMAPHORE% "
8988exit /b 0
9089
9190:error
9291echo Please check the detailed log that follows. 1 >& 2
9392type " %INIT_TOOLS_LOG% " 1 >& 2
94- exit /b 1
93+ exit /b 1
0 commit comments