diff --git a/tools/build-choco.bat b/tools/build-choco.bat old mode 100644 new mode 100755 diff --git a/tools/deploy.bat b/tools/deploy.bat index e6df0d5c..d3b1f998 100755 --- a/tools/deploy.bat +++ b/tools/deploy.bat @@ -1,21 +1,21 @@ @echo off setlocal +setlocal EnableDelayedExpansion -set CONFIG=Debug -set SUFFIX=x64 -set TARGET_MACHINE=WIN8DBG -if not X%1==X set TARGET_MACHINE=%1 -set TARGET_ACCOUNT=\Users\%USERNAME%\Downloads\winfsp\ -set TARGET=\\%TARGET_MACHINE%%TARGET_ACCOUNT% +set Config=Debug +set Suffix=x64 +set Deploy=C:\Deploy\winfsp +set Target=Win10DBG +if not X%1==X set Target=%1 -cd %~dp0.. -mkdir %TARGET% 2>nul -for %%f in (winfsp-%SUFFIX%.sys winfsp-%SUFFIX%.dll winfsp-tests-%SUFFIX%.exe fsbench-%SUFFIX%.exe fscrash-%SUFFIX%.exe memfs-%SUFFIX%.exe) do ( - copy build\VStudio\build\%CONFIG%\%%f %TARGET% >nul +set Files= +for %%f in (winfsp-%Suffix%.sys winfsp-%Suffix%.dll winfsp-tests-%Suffix%.exe memfs-%Suffix%.exe) do ( + if [!Files!] == [] ( + set Files='%~dp0..\build\VStudio\build\%Config%\%%f' + ) else ( + set Files=!Files!,'%~dp0..\build\VStudio\build\%Config%\%%f' + ) ) -copy tools\ifstest.bat %TARGET% >nul -echo sc create WinFsp type=filesys binPath=%%~dp0winfsp-%SUFFIX%.sys >%TARGET%sc-create.bat -echo sc start WinFsp >%TARGET%sc-start.bat -echo sc stop WinFsp >%TARGET%sc-stop.bat -echo sc delete WinFsp >%TARGET%sc-delete.bat + +powershell -NoProfile -ExecutionPolicy Bypass -Command "& '%~dp0deploy.ps1' -Name '%Target%' -Files !Files! -Destination '%Deploy%'" diff --git a/tools/deploy.ps1 b/tools/deploy.ps1 new file mode 100644 index 00000000..3920e051 --- /dev/null +++ b/tools/deploy.ps1 @@ -0,0 +1,35 @@ +param ( + [Parameter(Mandatory)][string]$Name, + [string]$CheckpointName, + [Parameter(Mandatory)][string[]]$Files, + [Parameter(Mandatory)][string]$Destination +) + +function Restore-VM ($Name, $CheckpointName) { + $VM = Get-VM -Name $Name + if ($VM.State -eq "Running") { + Stop-VM -Name $Name -TurnOff + } + + if (-not $CheckpointName) { + $Checkpoint = Get-VMCheckpoint -VMName $Name | + Sort-Object -Property CreationTime -Descending | + select -First 1 + } else { + $Checkpoint = Get-VMCheckpoint -VMName $Name -Name $CheckpointName + } + Restore-VMCheckpoint -VMCheckpoint $Checkpoint -Confirm:$false + + Start-VM -Name $Name +} + +function Deploy-VMFiles ($Name, $Files, $Destination) { + foreach ($File in $Files) { + $Leaf = Split-Path -Path $File -Leaf + $Dest = Join-Path $Destination $Leaf + Copy-VMFile -Name $Name -SourcePath $File -DestinationPath $Dest -FileSource Host -CreateFullPath -Force + } +} + +Restore-VM -Name $Name -CheckpointName $CheckpointName +Deploy-VMFiles -Name $Name -Files $Files -Destination $Destination