Skip to content

Commit

Permalink
Added host menu options for EXE / ZIP installation
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
bevanweiss committed Jun 26, 2024
1 parent 09a53e5 commit 299844b
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 40 deletions.
59 changes: 43 additions & 16 deletions src/test/sandbox/setup_sandbox.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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
67 changes: 43 additions & 24 deletions src/test/sandbox/startup.bat
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

0 comments on commit 299844b

Please sign in to comment.