|
| 1 | +# Run this command from TShell when connected to Holo VM. |
| 2 | +# It will install the webview2_sample_uwp and the runtime if pointed by $WebView2RuntimePath |
| 3 | + |
| 4 | +param( |
| 5 | + [Parameter(HelpMessage="When dealing only with runtime changes")] |
| 6 | + [switch] $SkipApp, |
| 7 | + |
| 8 | + [Parameter(HelpMessage="When dealing only with App changes")] |
| 9 | + [switch] $SkipRuntime, |
| 10 | + |
| 11 | + [string]$WebView2RuntimePath = $null |
| 12 | +) |
| 13 | + |
| 14 | +# Connection to the Holo VM |
| 15 | +if ((Get-Variable Device*).Count -eq 0) { |
| 16 | + Write-Error "You need to be conntected to a device. Use Open-Device command to connect to your Holo VM. See https://www.osgwiki.com/wiki/TShell_Commands#open-device:_connecting_tshell_to_target_device" |
| 17 | + Exit 1 |
| 18 | +} |
| 19 | +Write-Host "Connected to a device with IP=$((Get-Variable DeviceAddress).Value)" |
| 20 | + |
| 21 | +$dataTestBinPath = "U:\data\test\bin" |
| 22 | +$cmdPrefix = "cmdd $dataTestBinPath\mindeployappx.exe" |
| 23 | +# The mindeployappx.exe should be retrieved from |
| 24 | +# \\winbuilds\release\ni_release_svc_sydney_dev\22621.1070.230305-1600\amd64fre\bin\appxtools\deployappx |
| 25 | +# or a newer folder |
| 26 | + |
| 27 | +$scriptPath = Split-path -parent $myInvocation.MyCommand.Definition |
| 28 | + |
| 29 | +Write-Host "The script is in $scriptPath" |
| 30 | + |
| 31 | +if (!$SkipApp) { |
| 32 | + $uwpSampleAppPackageName = "WebView2-WinUI2-UWP-Sample_1.0.0.0_x64__ph1m9x8skttmg" |
| 33 | + |
| 34 | + # Check if the solution file exists |
| 35 | + $sln = $scriptPath + "\webview2_sample_uwp.sln" |
| 36 | + if (-Not (Test-Path $sln -PathType Leaf)) { |
| 37 | + Write-Error "The solution file is expected to exist: $sln" |
| 38 | + Exit 1 |
| 39 | + } |
| 40 | + |
| 41 | + # Build and create app package |
| 42 | + pushd (Get-ChildItem -Path "C:\Program Files*\Microsoft Visual Studio\*\*\MSBuild\Current\Bin")[0].FullName |
| 43 | + ./msbuild.exe $sln /property:Configuration=Debug /property:Platform=x64 /p:AppxBundle=Always /p:UapAppxPackageBuildMode=StoreUpload -verbosity:minimal |
| 44 | + popd |
| 45 | + |
| 46 | + Write-Host "Copying and installing app..." -ForegroundColor Cyan |
| 47 | + $command = $cmdPrefix |
| 48 | + $command += ' /Add /PackagePath:"' + $dataTestBinPath + '\webview2_sample_uwp_1.0.0.0_x64_Debug.msixbundle"' |
| 49 | + $command += ' /DependencyPackagePaths:"' |
| 50 | + |
| 51 | + # For each app dependency copy the appx file and update the command for deployment |
| 52 | + Get-ChildItem -Path $scriptPath\AppPackages\webview2_sample_uwp_1.0.0.0_Debug_Test\Dependencies\x64\ | ForEach-Object { |
| 53 | + Write-Host "dependencies += $_" |
| 54 | + putd $scriptPath\AppPackages\webview2_sample_uwp_1.0.0.0_Debug_Test\Dependencies\x64\$_ $dataTestBinPath |
| 55 | + $command += $dataTestBinPath + "\$_;" |
| 56 | + } |
| 57 | + |
| 58 | + putd $scriptPath\AppPackages\webview2_sample_uwp_1.0.0.0_Debug_Test\webview2_sample_uwp_1.0.0.0_x64_Debug.msixbundle $dataTestBinPath |
| 59 | + |
| 60 | + $command += '"' |
| 61 | + |
| 62 | + Write-Host $command -ForegroundColor Cyan |
| 63 | + Invoke-Expression $command |
| 64 | +} |
| 65 | + |
| 66 | +if ($WebView2RuntimePath) { |
| 67 | + Write-Host "Copying and installing runtime..." -ForegroundColor Cyan |
| 68 | + putd $WebView2RuntimePath $dataTestBinPath |
| 69 | + $fileName = Split-Path $WebView2RuntimePath -Leaf |
| 70 | + $command = $cmdPrefix + ' /Add /PackagePath:"' + $dataTestBinPath + '\' + $fileName + '"' |
| 71 | + Write-Host $command -ForegroundColor Cyan |
| 72 | + Invoke-Expression $command |
| 73 | +} |
0 commit comments