-
Notifications
You must be signed in to change notification settings - Fork 2
/
remotedebugsetup_uno.bat
330 lines (293 loc) · 16.3 KB
/
remotedebugsetup_uno.bat
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
@echo off
echo "--------------------------------------------------------------"
echo "| |"
echo "| Windows 10 VS Code Raspberry Pi |"
echo "| Remote Deployment and Debugging |"
echo "| Setup Script |"
echo "| |"
echo "| Uno Platform Version |"
echo "| |"
echo "--------------------------------------------------------------"
echo "| |"
echo "| This script will automatically create SSH keys, |"
echo "| copy the keys to the specified Raspberry Pi, |"
echo "| download and configure cwrsync. |"
echo "| |"
echo "| It will also create a new Uno Platform application named |"
echo "| <Hostname of your raspberry pi>_unotest. |"
echo "| |"
echo "| It will automatically create the launch.json, tasks.json |"
echo "| and workspace.code-workspace files |"
echo "| |"
echo "| Created By: Pete Gallagher |"
echo "| Version: 1.0 |"
echo "| Date: 06/02/2021 |"
echo "| Twitter: @pete_codes |"
echo "| |"
echo "--------------------------------------------------------------"
echo(
echo "--------------------------------------------------------------"
echo "| |"
echo "| Setting Pi Host Name and User Name |"
echo "| |"
echo "--------------------------------------------------------------"
echo(
set /p pihostname="Enter Raspberry Pi Host Name e.g. raspberrypi:"
set /p piusername="Enter Raspberry Pi User Name e.g. pi:"
echo Raspberry Pi Host Name Set to %pihostname%
echo Raspberry Pi User Name Set to %piusername%
echo(
echo "--------------------------------------------------------------"
echo "| |"
echo "| Setup Passwordless SSH Debugging? |"
echo "| |"
echo "--------------------------------------------------------------"
echo(
set /p setupSSH="Would you like to setup passwordless SSH Debugging for your Raspberry Pi? (y/n)"
echo Setup SSH Set to %setupSSH%
IF /I "%setupSSH%"=="y" (
echo(
echo "--------------------------------------------------------------"
echo "| |"
echo "| Creating SSH Keys |"
echo "| |"
echo "--------------------------------------------------------------"
echo(
if not exist c:\users\%username%\.ssh\id_rsa ssh-keygen -f "c:\\users\\%username%\\.ssh\\id_rsa" -t rsa -N ""
echo(
echo "--------------------------------------------------------------"
echo "| |"
echo "| Trusting Remote Raspberry Pi |"
echo "| |"
echo "--------------------------------------------------------------"
echo(
ssh-keyscan -H %pihostname% >> c:\users\%username%\.ssh\known_hosts
echo(
echo "--------------------------------------------------------------"
echo "| |"
echo "| Creating SSH Directory |"
echo "| |"
echo "| (Enter your login password) |"
echo "| |"
echo "--------------------------------------------------------------"
echo(
ssh pi@%pihostname% -oStrictHostKeyChecking=no "mkdir -p ~/.ssh"
echo(
echo "--------------------------------------------------------------"
echo "| |"
echo "| Copying SSH Keys to Raspberry Pi |"
echo "| |"
echo "| (Enter your login password) |"
echo "| |"
echo "--------------------------------------------------------------"
echo(
type c:\Users\%username%\.ssh\id_rsa.pub | ssh -oStrictHostKeyChecking=no pi@%pihostname% "cat >> ~/.ssh/authorized_keys"
echo(
echo "--------------------------------------------------------------"
echo "| |"
echo "| Downloading Visual Studio Debugger on Raspberry Pi |"
echo "| |"
echo "--------------------------------------------------------------"
echo(
ssh pi@%pihostname% "cd ~/ && curl -sSL https://aka.ms/getvsdbgsh | /bin/sh /dev/stdin -v latest -l ~/vsdbg"
echo(
echo "--------------------------------------------------------------"
echo "| |"
echo "| Downloading and Configuring cwRsync |"
echo "| |"
echo "--------------------------------------------------------------"
echo(
if not exist "c:\cwrsync\rsync.exe" (
mkdir c:\home\%USERNAME%\.ssh
cd c:\home
curl --output cwrsync.zip https://itefix.net/dl/free-software/cwrsync_6.2.7_x64_free.zip && tar -xf cwrsync.zip
rename bin cwrsync
move cwrsync c:\
copy %userprofile%\.ssh\* c:\home\%username%\.ssh
icacls c:\home /setowner %username% /R
icacls c:\home /inheritance:r /grant:r "%username%:(OI)(CI)F" /T
)
)
echo(
echo "--------------------------------------------------------------"
echo "| |"
echo "| Installing Uno Preview Templates |"
echo "| |"
echo "--------------------------------------------------------------"
echo(
cd c:/
dotnet new --install Uno.ProjectTemplates.Dotnet::3.5.0-dev.270
echo(
echo "--------------------------------------------------------------"
echo "| |"
echo "| Creating a .NET Uno Application |"
echo "| |"
echo "--------------------------------------------------------------"
echo(
dotnet new unoapp -o %pihostname%_unotest -ios=false -android=false -macos=false -wasm=false -skia-wpf=false -st=false
cd %pihostname%_unotest
echo(
echo "--------------------------------------------------------------"
echo "| |"
echo "| Creating .vscode Directory |"
echo "| |"
echo "--------------------------------------------------------------"
echo(
mkdir .vscode
cd .vscode
echo(
echo "--------------------------------------------------------------"
echo "| |"
echo "| Creating workspace.code-workspace |"
echo "| |"
echo "--------------------------------------------------------------"
echo(
echo { >> workspace.code-workspace
echo "folders": [ >> workspace.code-workspace
echo { >> workspace.code-workspace
echo "path": ".." >> workspace.code-workspace
echo } >> workspace.code-workspace
echo ], >> workspace.code-workspace
echo "settings": { >> workspace.code-workspace
echo "piUserName": "%piusername%", >> workspace.code-workspace
echo "piHostName": "%pihostname%" >> workspace.code-workspace
echo } >> workspace.code-workspace
echo } >> workspace.code-workspace
echo(
echo "--------------------------------------------------------------"
echo "| |"
echo "| Creating launch.json |"
echo "| |"
echo "--------------------------------------------------------------"
echo(
echo { >> launch.json
echo // Use IntelliSense to find out which attributes exist for C# debugging >> launch.json
echo // Use hover for the description of the existing attributes >> launch.json
echo // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md >> launch.json
echo "version": "0.2.0", >> launch.json
echo "configurations": [ >> launch.json
echo { >> launch.json
echo "name": ".NET Core Launch (console)", >> launch.json
echo "type": "coreclr", >> launch.json
echo "request": "launch", >> launch.json
echo "preLaunchTask": "build", >> launch.json
echo // If you have changed target frameworks, make sure to update the program path. >> launch.json
echo "program": "${workspaceFolder}/${workspaceFolderBasename}.Skia.Gtk/bin/Debug/net5.0/${workspaceFolderBasename}.Skia.Gtk.dll", >> launch.json
echo "args": [], >> launch.json
echo "cwd": "${workspaceFolder}", >> launch.json
echo // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console >> launch.json
echo "console": "internalConsole", >> launch.json
echo "stopAtEntry": false >> launch.json
echo }, >> launch.json
echo { >> launch.json
echo "name": ".NET Core Attach", >> launch.json
echo "type": "coreclr", >> launch.json
echo "request": "attach", >> launch.json
echo "processId": "${command:pickProcess}" >> launch.json
echo }, >> launch.json
echo { >> launch.json
echo "name": ".NET Core Launch (remote)", >> launch.json
echo "type": "coreclr", >> launch.json
echo "request": "launch", >> launch.json
echo "preLaunchTask": "RaspberryPiDeploy", >> launch.json
echo "program": "~/./dotnetdebug.sh", >> launch.json
echo "args": ["dotnet /home/${config:piUserName}/${workspaceFolderBasename}/${workspaceFolderBasename}.Skia.Gtk.dll"], >> launch.json
echo "cwd": "/home/pi/${workspaceFolderBasename}", >> launch.json
echo "stopAtEntry": false, >> launch.json
echo "console": "internalConsole", >> launch.json
echo "pipeTransport": { >> launch.json
echo "pipeCwd": "${workspaceFolder}/${workspaceFolderBasename}.Skia.Gtk", >> launch.json
echo "pipeProgram": "ssh", >> launch.json
echo "pipeArgs": [ >> launch.json
echo "${config:piUserName}@${config:piHostName}" >> launch.json
echo ], >> launch.json
echo "debuggerPath": "/home/pi/vsdbg/vsdbg" >> launch.json
echo } >> launch.json
echo } >> launch.json
echo ] >> launch.json
echo } >> launch.json
echo(
echo "--------------------------------------------------------------"
echo "| |"
echo "| Creating tasks.json |"
echo "| |"
echo "--------------------------------------------------------------"
echo(
echo { >> tasks.json
echo "version": "2.0.0", >> tasks.json
echo "tasks": [ >> tasks.json
echo { >> tasks.json
echo "label": "build", >> tasks.json
echo "command": "dotnet", >> tasks.json
echo "type": "process", >> tasks.json
echo "args": [ >> tasks.json
echo "build", >> tasks.json
echo "${workspaceFolder}/${workspaceFolderBasename}.Skia.Gtk/${workspaceFolderBasename}.Skia.Gtk.csproj", >> tasks.json
echo "/property:GenerateFullPaths=true", >> tasks.json
echo "/consoleloggerparameters:NoSummary" >> tasks.json
echo ], >> tasks.json
echo "problemMatcher": "$msCompile" >> tasks.json
echo }, >> tasks.json
echo { >> tasks.json
echo "label": "publish", >> tasks.json
echo "command": "dotnet", >> tasks.json
echo "type": "process", >> tasks.json
echo "args": [ >> tasks.json
echo "publish", >> tasks.json
echo "${workspaceFolder}/${workspaceFolderBasename}.Skia.Gtk/${workspaceFolderBasename}.Skia.Gtk.csproj", >> tasks.json
echo "/property:GenerateFullPaths=true", >> tasks.json
echo "/consoleloggerparameters:NoSummary" >> tasks.json
echo ], >> tasks.json
echo "problemMatcher": "$msCompile" >> tasks.json
echo }, >> tasks.json
echo { >> tasks.json
echo "label": "watch", >> tasks.json
echo "command": "dotnet", >> tasks.json
echo "type": "process", >> tasks.json
echo "args": [ >> tasks.json
echo "watch", >> tasks.json
echo "run", >> tasks.json
echo "${workspaceFolder}/${workspaceFolderBasename}.Skia.Gtk/${workspaceFolderBasename}.Skia.Gtk.csproj", >> tasks.json
echo "/property:GenerateFullPaths=true", >> tasks.json
echo "/consoleloggerparameters:NoSummary" >> tasks.json
echo ], >> tasks.json
echo "problemMatcher": "$msCompile" >> tasks.json
echo }, >> tasks.json
echo { >> tasks.json
echo "label": "RaspberryPiPublish", >> tasks.json
echo "command": "sh", >> tasks.json
echo "type": "shell", >> tasks.json
echo "dependsOn": "build", >> tasks.json
echo "windows": { >> tasks.json
echo "command": "cmd", >> tasks.json
echo "args": [ >> tasks.json
echo "/c", >> tasks.json
echo "\"dotnet publish ${workspaceFolder}/${workspaceFolderBasename}.Skia.Gtk/${workspaceFolderBasename}.Skia.Gtk.csproj -r linux-arm -o ${workspaceFolderBasename}.Skia.Gtk\\bin\\linux-arm\\publish --no-self-contained\"" >> tasks.json
echo ], >> tasks.json
echo "problemMatcher": [] >> tasks.json
echo } >> tasks.json
echo }, >> tasks.json
echo { >> tasks.json
echo "label": "RaspberryPiDeploy", >> tasks.json
echo "type": "shell", >> tasks.json
echo "dependsOn": "RaspberryPiPublish", >> tasks.json
echo "presentation": { >> tasks.json
echo "reveal": "always", >> tasks.json
echo "panel": "new" >> tasks.json
echo }, >> tasks.json
echo "windows": { >> tasks.json
echo "command": "c:\\cwrsync\\rsync -rvuz --rsh=\"c:\\cwrsync\\ssh\" --chmod=700 ${workspaceFolderBasename}.Skia.Gtk/bin/linux-arm/publish/ ${config:piUserName}@${config:piHostName}:/home/${config:piUserName}/${workspaceFolderBasename}/" >> tasks.json
echo }, >> tasks.json
echo "problemMatcher": [] >> tasks.json
echo } >> tasks.json
echo ] >> tasks.json
echo } >> tasks.json
echo(
echo "--------------------------------------------------------------"
echo "| |"
echo "| Opening Project in VS Code |"
echo "| |"
echo "--------------------------------------------------------------"
echo(
cd c:\%pihostname%_unotest\.vscode
code workspace.code-workspace