From cdc08b4d43266ba53e2a23549586e668bf66765f Mon Sep 17 00:00:00 2001 From: sneurlax <sneurlax@gmail.com> Date: Mon, 5 Jun 2023 16:05:14 -0500 Subject: [PATCH] upgrade powershell script TODO enable overwriting files when extracting archive ... or delete folder prior to extraction? --- scripts/windows/deps.ps1 | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/scripts/windows/deps.ps1 b/scripts/windows/deps.ps1 index db00e4fb2..2d90ed7fe 100644 --- a/scripts/windows/deps.ps1 +++ b/scripts/windows/deps.ps1 @@ -1,9 +1,25 @@ # Create C:\development -New-Item -Path 'C:\development' -ItemType Directory +New-Item -Path 'C:\development' -ItemType Directory -ErrorAction Ignore + +# $wc = [System.Net.WebClient]::new() +# $publishedHash = '8E28E54D601F0751922DE24632C1E716B4684876255CF82304A9B19E89A9CCAC' +# $FileHash = Get-FileHash -InputStream ($wc.OpenRead("C:\development\flutter_windows_3.7.12-stable.zip")) + +# if (-Not [System.IO.File]::Exists("C:\development\flutter_windows_3.7.12-stable.zip") or -Not ($FileHash.Hash -eq $publishedHash)) { +# } else { # Download flutter_windows_3.7.12-stable.zip -Invoke-WebRequest "https://storage.googleapis.com/flutter_infra_release/releases/stable/windows/flutter_windows_3.7.12-stable.zip" -OutFile "C:\development\flutter_windows_3.7.12-stable.zip" +# Write-Output "Downloading flutter_windows_3.7.12-stable.zip" +# $ProgressPreference = 'SilentlyContinue' # Speed up download process, see https://stackoverflow.com/questions/28682642/powershell-why-is-using-invoke-webrequest-much-slower-than-a-browser-download +# Invoke-WebRequest "https://storage.googleapis.com/flutter_infra_release/releases/stable/windows/flutter_windows_3.7.12-stable.zip" -OutFile "C:\development\flutter_windows_3.7.12-stable.zip" +# } + # Extract Flutter SDK -Expand-Archive "C:\development\flutter_windows_3.7.12-stable.zip" -DestinationPath "C:\development" +Write-Output "Extracting flutter_windows_3.7.12-stable.zip" +$progressPreference = 'SilentlyContinue' # Speed up extraction process, see https://github.com/PowerShell/Microsoft.PowerShell.Archive/issues/32#issuecomment-642582179 +# Add-MpPreference -ExclusionPath C:\development +# Expand-Archive "C:\development\flutter_windows_3.7.12-stable.zip" -DestinationPath "C:\development" +Add-Type -Assembly "System.IO.Compression.Filesystem" +[System.IO.Compression.ZipFile]::ExtractToDirectory("C:\development\flutter_windows_3.7.12-stable.zip", "C:\development") # See https://stackoverflow.com/a/69239861 function Add-Path { @@ -52,6 +68,8 @@ function Add-Path { # Add Flutter SDK to PATH if it's not there already if ($Env:Path -split ";" -contains 'C:\development\flutter\bin') { + Write-Output "Flutter SDK in PATH, done" } else { + Write-Output "Attempting to add Flutter SDK to PATH" Add-Path("C:\development\flutter\bin") }