go.cmd 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  1. @echo off
  2. rem Checking for PowerShell Core using PowerShell for Windows...
  3. powershell -NoProfile -NonInteractive -Command "& {Get-Command -Name pwsh -ErrorAction Stop}" > NUL
  4. if ERRORLEVEL 1 (
  5. rem Ask the user whether they should install the dependencies. Note that this
  6. rem code path never runs in CI because pwsh is always explicitly installed.
  7. rem Time out after 5 minutes, defaulting to 'N'
  8. choice /c yn /t 300 /d n /m "PowerShell Core is required. Install now"
  9. if ERRORLEVEL 2 (
  10. echo Aborting due to unmet dependencies.
  11. exit /b 1
  12. )
  13. rem Check for a .NET Core runtime using PowerShell for Windows...
  14. powershell -NoProfile -NonInteractive -Command "& {if (-not (dotnet --list-runtimes | Select-String 'Microsoft\.NETCore\.App' -Quiet)) {exit 1}}" > NUL
  15. rem Install .NET Core if missing to provide PowerShell Core's runtime library.
  16. if ERRORLEVEL 1 (
  17. rem Time out after 5 minutes, defaulting to 'N'
  18. choice /c yn /t 300 /d n /m "PowerShell Core requires .NET Core for its runtime library. Install now"
  19. if ERRORLEVEL 2 (
  20. echo Aborting due to unmet dependencies.
  21. exit /b 1
  22. )
  23. winget install --accept-package-agreements --id Microsoft.DotNet.Runtime.8 -e --source winget
  24. )
  25. rem Now install PowerShell Core.
  26. winget install --accept-package-agreements --id Microsoft.PowerShell -e --source winget
  27. if ERRORLEVEL 0 echo Please re-run this script within a new console session to pick up PATH changes.
  28. rem Either way we didn't build, so return 1.
  29. exit /b 1
  30. )
  31. pwsh -NoProfile -ExecutionPolicy Bypass "%~dp0..\tool\gocross\gocross-wrapper.ps1" %*