From 299844ba665d2e1c38ecdb0e7802c66c681ff62b Mon Sep 17 00:00:00 2001 From: Bevan Weiss Date: Wed, 26 Jun 2024 18:41:08 +1000 Subject: [PATCH] Added host menu options for EXE / ZIP installation Removed ARM64/AMD64 folders for dotnet, the Sandbox MUST match the host here, so no point downloading the installer for the non-host platform. Debugger could probably be reduced in the same manner, but have not in this iteration. Signed-off-by: Bevan Weiss --- src/test/sandbox/setup_sandbox.bat | 59 +++++++++++++++++++------- src/test/sandbox/startup.bat | 67 +++++++++++++++++++----------- 2 files changed, 86 insertions(+), 40 deletions(-) diff --git a/src/test/sandbox/setup_sandbox.bat b/src/test/sandbox/setup_sandbox.bat index c4378f520..dc462324b 100644 --- a/src/test/sandbox/setup_sandbox.bat +++ b/src/test/sandbox/setup_sandbox.bat @@ -2,20 +2,41 @@ @echo off SET DOTNET_VERSION=8.0 -if not exist AMD64 (mkdir AMD64) -if not exist ARM64 (mkdir ARM64) -REM if not exist VSTest (mkdir VSTest) - -@echo on -REM curl -L0 https://aka.ms/dotnet/%DOTNET_VERSION%/dotnet-runtime-win-x64.zip --output ".\AMD64\dotnet-runtime.zip" -curl -L0 https://aka.ms/dotnet/%DOTNET_VERSION%/dotnet-sdk-win-x64.zip --output ".\AMD64\dotnet-sdk.zip" -REM curl -L0 https://aka.ms/dotnet/%DOTNET_VERSION%/dotnet-runtime-win-arm64.zip --output ".\ARM64\dotnet-runtime.zip" -curl -L0 https://aka.ms/dotnet/%DOTNET_VERSION%/dotnet-sdk-win-arm64.zip --output ".\ARM64\dotnet-sdk.zip" -@echo off +:MENU +cls +echo [0] Setup EXE install of DotNet for Sandbox +echo [1] Setup ZIP install of DotNet for Sandbox +echo [q] Quit +set /P "Option=Please select install option: " +if "%Option%"=="q" goto END +if "%Option%"=="0" goto EXE +if "%Option%"=="1" goto ZIP + +:MENUERROR +cls +echo ERROR: Invalid Option Selected!! +pause +goto MENU + +:EXE +echo EXE> dotnet.cfg +if %PROCESSOR_ARCHITECTURE%=="ARM64" ( + curl -L0 https://aka.ms/dotnet/%DOTNET_VERSION%/dotnet-sdk-win-arm64.exe --output ".\dotnet-sdk.exe" +) else ( + curl -L0 https://aka.ms/dotnet/%DOTNET_VERSION%/dotnet-sdk-win-x64.exe --output ".\dotnet-sdk.exe" +) +goto VSDEBUG -REM curl -L0 https://aka.ms/vs/17/release/RemoteTools.amd64ret.enu.exe --output ".\AMD64\RemoteTools.exe" -REM curl -L0 https://aka.ms/vs/17/release/RemoteTools.arm64ret.enu.exe --output ".\ARM64\RemoteTools.exe" +:ZIP +echo ZIP> dotnet.cfg +if %PROCESSOR_ARCHITECTURE%=="ARM64" ( + curl -L0 https://aka.ms/dotnet/%DOTNET_VERSION%/dotnet-sdk-win-arm64.zip --output ".\dotnet-sdk.zip" +) else ( + curl -L0 https://aka.ms/dotnet/%DOTNET_VERSION%/dotnet-sdk-win-x64.zip --output ".\dotnet-sdk.zip" +) +goto VSDEBUG +:VSDEBUG for /f "usebackq tokens=*" %%i in (`"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -requires Microsoft.VisualStudio.Debugger.Remote -property installationPath`) do ( set VsInstallDir=%%i ) @@ -28,12 +49,18 @@ if not "!VsInstallDir!"=="" ( echo. echo Have found VisualStudio Debugger at '%VsInstallDir%' set /P "Confirm=Do you wish to copy it for use by the Sandbox? (Y / N):" - echo Confirm = %Confirm% - @if "%Confirm%"=="Y" or "%Confirm%"="y" ( - XCOPY "%VsInstallDir%\Common7\IDE\Remote Debugger\*" ".\Debugger\" /E /Y - ) + if "%Confirm%"=="Y" goto VSDEBUG_COPY + if "%Confirm%"=="y" goto VSDEBUG_COPY + goto END ) +goto END + +:VSDEBUG_COPY +if not exist Debugger (mkdir Debugger) +XCOPY "%VsInstallDir%\Common7\IDE\Remote Debugger\*" ".\Debugger\" /E /Y > nul +echo Debugger files copied +:END pause @endlocal diff --git a/src/test/sandbox/startup.bat b/src/test/sandbox/startup.bat index ce0f2bbd9..7b9b603fe 100644 --- a/src/test/sandbox/startup.bat +++ b/src/test/sandbox/startup.bat @@ -1,28 +1,19 @@ @setlocal +@echo off SET DOTNET_VERSION=8.0 SET SANDBOX_FILES=C:\sandbox +set /p InstallMethod=<%SANDBOX_FILES%\dotnet.cfg + pushd "%TEMP%" +if "%InstallMethod%"=="EXE" goto EXE +if "%InstallMethod%"=="ZIP" goto ZIP +goto ERROR_NO_CONFIG +:ZIP mkdir "%ProgramFiles%\dotnet" -REM @if exist %SANDBOX_FILES%\%PROCESSOR_ARCHITECTURE%\dotnet-runtime.zip ( -REM tar -oxzf "%SANDBOX_FILES%\%PROCESSOR_ARCHITECTURE%\dotnet-runtime.zip" -C "%ProgramFiles%\dotnet" -REM ) else ( -REM if %PROCESSOR_ARCHITECTURE%=="ARM64" ( -REM curl -L https://aka.ms/dotnet/%DOTNET_VERSION%/dotnet-runtime-win-arm64.zip --output dotnet-runtime.zip -REM ) else ( -REM curl -L https://aka.ms/dotnet/%DOTNET_VERSION%/dotnet-runtime-win-x64.zip --output dotnet-runtime.zip -REM ) -REM if %errorlevel% NEQ 0 ( -REM echo No pre-provided dotnet runtime, and failed to download. Confirm networking is available. -REM goto :ERROR -REM ) -REM tar -oxzf dotnet-runtime.zip -C "%ProgramFiles%\dotnet" -REM del dotnet-runtime.zip -REM ) - -@if exist %SANDBOX_FILES%\%PROCESSOR_ARCHITECTURE%\dotnet-sdk.zip ( - tar -oxzf "%SANDBOX_FILES%\%PROCESSOR_ARCHITECTURE%\dotnet-sdk.zip" -C "%ProgramFiles%\dotnet" +if exist %SANDBOX_FILES%\dotnet-sdk.zip ( + tar -oxzf "%SANDBOX_FILES%\dotnet-sdk.zip" -C "%ProgramFiles%\dotnet" ) else ( if %PROCESSOR_ARCHITECTURE%=="ARM64" ( curl -L https://aka.ms/dotnet/%DOTNET_VERSION%/dotnet-sdk-win-arm64.zip --output dotnet-sdk.zip @@ -31,21 +22,49 @@ REM ) ) if %errorlevel% NEQ 0 ( echo "No pre-provided dotnet sdk, and failed to download. Confirm networking is available." - goto ERROR + goto ERROR_NO_DOTNET ) tar -oxzf dotnet-sdk.zip -C "%ProgramFiles%\dotnet" del dotnet-sdk.zip ) +goto PROCEED -@endlocal +:EXE +if exist %SANDBOX_FILES%\dotnet-sdk.exe ( + "%SANDBOX_FILES%\dotnet-sdk.exe" /install /quiet /norestart +) else ( + if %PROCESSOR_ARCHITECTURE%=="ARM64" ( + curl -L https://aka.ms/dotnet/%DOTNET_VERSION%/dotnet-sdk-win-arm64.exe --output dotnet-sdk.exe + ) else ( + curl -L https://aka.ms/dotnet/%DOTNET_VERSION%/dotnet-sdk-win-x64.exe --output dotnet-sdk.exe + ) + if %errorlevel% NEQ 0 ( + echo "No pre-provided dotnet sdk, and failed to download. Confirm networking is available." + goto ERROR_NO_DOTNET + ) + dotnet-sdk.exe /install /quiet /norestart +) +goto PROCEED + +:PROCEED +endlocal SETX PATH "%PATH%;%ProgramFiles%\dotnet" /M SET PATH=%PATH%;%ProgramFiles%\dotnet + dotnet nuget locals all --clear dotnet help +popd +cd c:\build +start "Menu" cmd /c C:\sandbox\runtest_menu.bat +goto END -:ERROR +:ERROR_NO_CONFIG +start "ERROR" CMD /c echo ERROR: Host configuration has not been run, run setup_sandbox.bat first ^& pause +goto END -@popd -cd c:\build -start cmd /c C:\sandbox\runtest_menu.bat + +:ERROR_NO_DOTNET +start "ERROR" CMD /c echo ERROR: Failed to find dotnet install, and download failed. Run setup_sandbox.bat again ^& pause + +:END