root.ps1 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. $logFile = Join-Path -Path $PSScriptRoot -ChildPath "output.log"
  2. Start-Transcript -Path $logFile
  3. $title = 'Confirmation'
  4. $question = 'Are you sure you want to proceed?'
  5. $choices = '&Yes', '&No'
  6. # check if there are spaces in the path
  7. if ($PSScriptRoot -match " ") {
  8. Write-Host "Warning: The installation directory's path contains a space character. Conda will fail to install. Please change the directory."
  9. Write-Host "For example, C:\AI\TTS-Generation-WebUI\"
  10. # ask user if they still want to continue
  11. $decision = $Host.UI.PromptForChoice($title, $question, $choices, 1)
  12. if ($decision -eq 1) {
  13. exit 1
  14. }
  15. }
  16. # check if long paths are enabled
  17. $longPathsEnabled = (Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled').LongPathsEnabled
  18. if ($longPathsEnabled -ne 1) {
  19. Write-Host "Warning: Long paths are not enabled, please enable them and restart the installer."
  20. Write-Host "The installer is likely to fail without long paths enabled, that is why this is required."
  21. Write-Host "You can enable long paths by running the enable_long_paths.reg file in the installer_scripts folder."
  22. Write-Host "For more information, please visit:"
  23. Write-Host "https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry#enable-long-paths-in-windows-10-version-1607-and-later"
  24. # ask user if they still want to continue
  25. $decision = $Host.UI.PromptForChoice($title, $question, $choices, 1)
  26. if ($decision -eq 1) {
  27. exit 1
  28. }
  29. }
  30. & "$PSScriptRoot\init_mamba.bat"
  31. if ($LASTEXITCODE -ne 0) {
  32. Write-Host "Failed to init mamba, exiting..."
  33. exit 1
  34. }
  35. $env:Path += ";$PSScriptRoot\..\installer_files\env\Library\bin\"
  36. if (!(Get-Command "vswhere" -ErrorAction SilentlyContinue)) {
  37. Write-Host "Critical Warning: vswhere is not installed, automatic validation of Visual Studio Build Tools installation will not work."
  38. Write-Host "For more information, please visit:"
  39. Write-Host "https://github.com/microsoft/vswhere"
  40. Write-Host "The app will try to launch but might fail."
  41. } else {
  42. Write-Host "vswhere is installed, checking for Visual Studio Build Tools installation..."
  43. $vswhereOutput = vswhere -products * -format json | ConvertFrom-Json
  44. if ($vswhereOutput.length -eq 0) {
  45. Write-Host "Warning: Visual Studio compiler is not installed."
  46. if (!(Get-Command "winget" -ErrorAction SilentlyContinue)) {
  47. Write-Host "Warning: winget is not installed, automatic installation of Visual Studio Build Tools will not work."
  48. Write-Host "Please install Visual Studio Build Tools manually and restart the installer."
  49. Write-Host "(Note: The full Visual Studio is NOT required, only the Build Tools)"
  50. Write-Host "For more information, please visit:"
  51. Write-Host "https://learn.microsoft.com/en-us/cpp/build/vscpp-step-0-installation?view=msvc-170"
  52. exit 1
  53. } else {
  54. Write-Host "Attempting to install Visual Studio Build Tools using winget..."
  55. Write-Host "This will open a new window, please follow the instructions."
  56. # quiet install does not seem user friendly
  57. # winget install Microsoft.VisualStudio.2022.BuildTools --silent --override "--wait --quiet --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"
  58. winget install Microsoft.VisualStudio.2022.BuildTools --silent --override "--wait --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"
  59. }
  60. } else {
  61. Write-Host "Visual Studio Build Tools is installed, continuing..."
  62. }
  63. }
  64. & "$PSScriptRoot\init_app.bat"
  65. if ($LASTEXITCODE -ne 0) {
  66. Write-Host "Failed to init the app, exiting..."
  67. exit 1
  68. }
  69. & "$PSScriptRoot\start_app.bat"
  70. if ($LASTEXITCODE -ne 0) {
  71. Write-Host "Failed to start the app, exiting..."
  72. exit 1
  73. }
  74. Stop-Transcript