Tobias Simetsreiter 3 lat temu
rodzic
commit
8b0598c957
5 zmienionych plików z 87 dodań i 5 usunięć
  1. 1 0
      .gitignore
  2. 42 5
      build.ps1
  3. 4 0
      sfx/sfx_main.txt
  4. 4 0
      wintermsfx/main.ps1
  5. 36 0
      wintermsfx/wintermportable.ps1

+ 1 - 0
.gitignore

@@ -1 +1,2 @@
 dist
+build

+ 42 - 5
build.ps1

@@ -1,17 +1,54 @@
 param(
     $sevenzip = "C:\Program Files\7-Zip\7z.exe"
 )
+cd $PSSCriptRoot
+
+$dist = "dist"
+$src = "WinImager"
+$sfx = "sfx"
 
-$dist = "$PSScriptRoot\dist"
-$src = "$PSScriptRoot\WinImager"
-$sfx = "$PSScriptRoot\sfx"
 
 $szfile = "$dist/WinImager.7z"
 $exefile = "$dist/WinImager.exe"
 
-New-Item -itemtype directory -Path "$PSScriptRoot\dist" -Force
+New-Item -itemtype directory -Path "$dist" -Force
 Remove-Item -Force $szfile
 
 &$sevenzip a $szfile $src "-xr0!*.log"
 
-Get-Content -Encoding Byte -Read 512 -Path "$sfx/7zsd_All_x64.sfx","$sfx/sfx_config.txt",$szfile | Set-Content -Encoding Byte $exefile
+Get-Content -Encoding Byte -Read 512 -Path "$sfx/7zsd_All_x64.sfx","$sfx/sfx_config.txt",$szfile | Set-Content -Encoding Byte $exefile
+
+
+$wintermsfx_build="wintermsfx\build"
+
+if ($null -eq (Get-Item "$wintermsfx_build\windowsterminal")){
+    .\wintermsfx\wintermportable.ps1
+}
+Copy-Item -Force .\wintermsfx\main.ps1 "$wintermsfx_build\main.ps1"
+
+cd $wintermsfx_build
+Remove-Item -Force windowsterminal.7z
+
+$PSVERSION="7.2.5"
+$PSFILE="PowerShell-$PSVERSION-win-x64.zip"
+$PSURL="https://github.com/PowerShell/PowerShell/releases/download/v$PSVERSION/$PSFILE" 
+
+$PSTOOLSFILE="PSTools.zip"
+$PSTOOLSURL="https://download.sysinternals.com/files/$PSTOOLSFILE"
+
+if ($null -eq (Get-Item $PSFILE)){
+    Invoke-WebRequest -Uri $PSURL -OutFile $PSFILE
+}
+if ($null -eq (Get-Item $PSTOOLSFILE)){
+    Invoke-WebRequest -Uri $PSTOOLSURL -OutFile $PSTOOLSFILE
+}
+
+Remove-Item -Recurse -Force windowsterminal\powershell\
+Expand-Archive $PSFILE -DestinationPath windowsterminal\powershell\
+Expand-Archive $PSTOOLSFILE -DestinationPath windowsterminal\powershell\
+
+&$sevenzip a windowsterminal.7z main.ps1 windowsterminal
+
+cd $PSSCriptRoot
+
+gc $sfx/7zsd_All_x64.sfx,$sfx/sfx_main.txt,wintermsfx\build\windowsterminal.7z -Encoding Byte -Read 512 | sc -Encoding Byte "$dist\wintermsfx.exe"

+ 4 - 0
sfx/sfx_main.txt

@@ -0,0 +1,4 @@
+;!@Install@!UTF-8!
+Title="WinImager"
+RunProgram="powershell.exe -ExecutionPolicy RemoteSigned %%T\main.ps1"
+;!@InstallEnd@!

+ 4 - 0
wintermsfx/main.ps1

@@ -0,0 +1,4 @@
+
+cd $PSScriptRoot
+.\windowsterminal\wt.exe .\windowsterminal\powershell\pwsh.exe 
+sleep 2

+ 36 - 0
wintermsfx/wintermportable.ps1

@@ -0,0 +1,36 @@
+param(
+    $destination = $PSSCriptRoot + '.\build\windowsterminal'
+)
+if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))  
+{  
+  $arguments = "& '" +$myinvocation.mycommand.definition + "'"
+  Start-Process powershell -Verb runAs -ArgumentList $arguments
+  Break
+}
+
+
+
+# search for installed apps...
+Get-ChildItem "$env:programfiles\WindowsApps\" | 
+# pick Windows Terminal...
+Where-Object name -like *windowsterminal* | 
+# find the executable...
+Get-ChildItem -Filter wt.exe | 
+# identify executable versions...
+Select-Object -ExpandProperty VersionInfo | 
+# sort versions...
+Sort-Object -Property ProductVersion -Descending | 
+# pick the latest...
+Select-Object -First 1 -ExpandProperty filename | 
+# get parent folder...
+Split-Path | 
+# dump folder content...
+Get-ChildItem | 
+# copy to destination folder
+Copy-Item -Destination $destination -Force
+
+# open folder
+# explorer $destination
+
+# run portable app
+# Start-Process -FilePath "$destination\wt.exe"