From 85d10014c22a3c27331bc1eb1ef44215633e18d3 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Fri, 5 May 2017 16:14:59 +0200 Subject: [PATCH] Make new build work when there's spaces in the current path --- build/Build.bat | 24 ++++++++++++------------ build/BuildBelle.bat | 19 ++++++++++--------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/build/Build.bat b/build/Build.bat index 660cfa34be..408f37c13d 100644 --- a/build/Build.bat +++ b/build/Build.bat @@ -50,41 +50,41 @@ REM but the path setting is lost due to SETLOCAL path=C:\Program Files (x86)\Git\cmd;C:\Program Files\Git\cmd;%PATH% SET toolsFolder=%CD%\tools\ -IF NOT EXIST %toolsFolder% ( +IF NOT EXIST "%toolsFolder%" ( MD tools ) SET nuGetExecutable=%CD%\tools\nuget.exe -IF NOT EXIST %nuGetExecutable% ( +IF NOT EXIST "%nuGetExecutable%" ( ECHO Getting NuGet so we can fetch some tools ECHO Downloading https://dist.nuget.org/win-x86-commandline/latest/nuget.exe to %nuGetExecutable% powershell -Command "(New-Object Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', '%nuGetExecutable%')" ) :: We need 7za.exe for BuildBelle.bat -IF NOT EXIST %toolsFolder%7za.exe ( +IF NOT EXIST "%toolsFolder%7za.exe" ( ECHO 7zip not found - fetching now - %nuGetExecutable% install 7-Zip.CommandLine -OutputDirectory %toolsFolder% -Verbosity quiet + "%nuGetExecutable%" install 7-Zip.CommandLine -OutputDirectory tools -Verbosity quiet ) -:: We need 7za.exe for VS2017+ -IF NOT EXIST %toolsFolder%vswhere.exe ( +:: We need vswhere.exe for VS2017+ +IF NOT EXIST "%toolsFolder%vswhere.exe" ( ECHO vswhere not found - fetching now - %nuGetExecutable% install vswhere -OutputDirectory %toolsFolder% -Verbosity quiet + "%nuGetExecutable%" install vswhere -OutputDirectory tools -Verbosity quiet ) :: Put 7za.exe and vswhere.exe in a predictable path (not version specific) -FOR /f "delims=" %%A in ('dir %toolsFolder%7-Zip.CommandLine.* /b') DO SET "sevenZipExePath=%toolsFolder%%%A\" -MOVE %sevenZipExePath%tools\7za.exe %toolsFolder%7za.exe +FOR /f "delims=" %%A in ('dir "%toolsFolder%7-Zip.CommandLine.*" /b') DO SET "sevenZipExePath=%toolsFolder%%%A\" +MOVE "%sevenZipExePath%tools\7za.exe" "%toolsFolder%7za.exe" -FOR /f "delims=" %%A in ('dir %toolsFolder%vswhere.* /b') DO SET "vswhereExePath=%toolsFolder%%%A\" -MOVE %vswhereExePath%tools\vswhere.exe %toolsFolder%vswhere.exe +FOR /f "delims=" %%A in ('dir "%toolsFolder%vswhere.*" /b') DO SET "vswhereExePath=%toolsFolder%%%A\" +MOVE "%vswhereExePath%tools\vswhere.exe" "%toolsFolder%vswhere.exe" ECHO. ECHO Making sure we have a web.config IF NOT EXIST %CD%\..\src\Umbraco.Web.UI\web.config COPY %CD%\..\src\Umbraco.Web.UI\web.Template.config %CD%\..\src\Umbraco.Web.UI\web.config -for /f "usebackq tokens=1* delims=: " %%i in (`%CD%\tools\vswhere.exe -latest -requires Microsoft.Component.MSBuild`) do ( +for /f "usebackq tokens=1* delims=: " %%i in (`"%CD%\tools\vswhere.exe" -latest -requires Microsoft.Component.MSBuild`) do ( if /i "%%i"=="installationPath" set InstallDir=%%j ) diff --git a/build/BuildBelle.bat b/build/BuildBelle.bat index ae2d5ba8b5..78b7736c2b 100644 --- a/build/BuildBelle.bat +++ b/build/BuildBelle.bat @@ -8,23 +8,25 @@ ECHO Current folder: %CD% SET nodeFileName=node-v6.9.1-win-x86.7z SET nodeExtractFolder=%toolsFolder%node.js.691 -IF NOT EXIST %nodeExtractFolder% ( +IF NOT EXIST "%nodeExtractFolder%" ( ECHO Downloading http://nodejs.org/dist/v6.9.1/%nodeFileName% to %toolsFolder%%nodeFileName% powershell -Command "(New-Object Net.WebClient).DownloadFile('http://nodejs.org/dist/v6.9.1/%nodeFileName%', '%toolsFolder%%nodeFileName%')" ECHO Extracting %nodeFileName% to %nodeExtractFolder% - %toolsFolder%\7za.exe x %toolsFolder%\%nodeFileName% -o%nodeExtractFolder% -aos > nul + "%toolsFolder%\7za.exe" x "%toolsFolder%\%nodeFileName%" -o"%nodeExtractFolder%" -aos > nul ) -FOR /f "delims=" %%A in ('dir %nodeExtractFolder%\node* /b') DO SET "nodePath=%nodeExtractFolder%\%%A" +FOR /f "delims=" %%A in ('dir "%nodeExtractFolder%\node*" /b') DO SET "nodePath=%nodeExtractFolder%\%%A" + SET nuGetExecutable=%CD%\tools\nuget.exe -IF NOT EXIST %nuGetExecutable% ( +IF NOT EXIST "%nuGetExecutable%" ( ECHO Downloading https://dist.nuget.org/win-x86-commandline/latest/nuget.exe to %nuGetExecutable% powershell -Command "(New-Object Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', '%nuGetExecutable%')" ) SET drive=%CD:~0,2% SET nuGetFolder=%drive%\packages\ -FOR /f "delims=" %%A in ('dir %nuGetFolder%npm.* /b') DO SET "npmPath=%nuGetFolder%%%A\" +FOR /f "delims=" %%A in ('dir "%nuGetFolder%npm.*" /b') DO SET "npmPath=%nuGetFolder%%%A\" + IF [%npmPath%] == [] GOTO :installnpm IF NOT [%npmPath%] == [] GOTO :build @@ -32,7 +34,7 @@ IF NOT [%npmPath%] == [] GOTO :build ECHO Downloading npm ECHO Configured packages folder: %nuGetFolder% ECHO Installing Npm NuGet Package - %nuGetExecutable% install Npm -OutputDirectory %nuGetFolder% -Verbosity detailed + "%nuGetExecutable%" install Npm -OutputDirectory %nuGetFolder% -Verbosity detailed REM Ensures that we look for the just downloaded NPM, not whatever the user has installed on their machine FOR /f "delims=" %%A in ('dir %nuGetFolder%npm.* /b') DO SET "npmPath=%nuGetFolder%%%A\" GOTO :build @@ -40,8 +42,7 @@ IF NOT [%npmPath%] == [] GOTO :build :build ECHO Adding Npm and Node to path REM SETLOCAL is on, so changes to the path not persist to the actual user's path - PATH=%npmPath%;%nodePath%;%PATH% - + PATH="%npmPath%";"%nodePath%";%PATH% SET buildFolder=%CD% ECHO Change directory to %CD%\..\src\Umbraco.Web.UI.Client\ @@ -55,4 +56,4 @@ IF NOT [%npmPath%] == [] GOTO :build call grunt build --buildversion=%release% ECHO Move back to the build folder - CD %buildFolder% \ No newline at end of file + CD "%buildFolder%" \ No newline at end of file