forked from torizon/vscode-torizon-templates
-
Notifications
You must be signed in to change notification settings - Fork 1
/
configUnoHotReload.ps1
49 lines (36 loc) · 1.17 KB
/
configUnoHotReload.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
param(
[string] $workspaceFolder
)
$errorActionPreference = "Stop"
# get the path of the xml file
$_files = `
Get-ChildItem `
-Path $workspaceFolder/*.Skia.* `
-Recurse `
-Filter *.csproj
$_csprojPath = $_files[0].FullName
# load the csproj file as XML
[xml] $_csproj = Get-Content -Path $_csprojPath
# get my ip address
$hostIp = `
(Get-Content $workspaceFolder/.vscode/settings.json `
| ConvertFrom-Json -Depth 100).host_ip
if ([string]::IsNullOrEmpty($hostIp)) {
Write-Host -ForegroundColor Yellow `
"`n⚠️ The host ip is not set in the .vscode/settings.json file"
Write-Host -ForegroundColor Yellow `
"Did you forget to set a default device?"
Write-Host `
"https://developer.toradex.com/torizon/application-development/ide-extension/connect-a-torizoncore-target-device `n"
Write-Host -ForegroundColor Red `
"❌ Failed`n`n"
exit 69
}
Write-Host "Injecting the host ip $hostIp"
Write-Host "into the csproj file: "
Write-Host "$_csprojPath `n`n"
# update it
$_csproj.Project.PropertyGroup.UnoRemoteControlHost = $hostIp;
# save it
$_csproj.Save($_csprojPath)
Write-Host "✅ Success! `n"