Skip to content

Commit 4201dc1

Browse files
authored
[samples] Add Tasks to debug Samples in VSCode (#5880)
Update [`tasks.json`][0] to add the following tasks to VS Code: * `build-sample` * `run-sample` * `build-sample-under-dotnet` * `run-sample-under-dotnet` These tasks build or run one of the following projects; when running the task, the developer will be prompted for which project to use: * `samples/HelloWorld/HelloWorld.csproj` * `samples/HelloWorld/HelloWorld.DotNet.csproj` * `samples/VSAndroidApp/VSAndroidApp.csproj` These projects may also be debugged within VSCode. [0]: https://code.visualstudio.com/docs/editor/tasks-v1
1 parent c193141 commit 4201dc1

File tree

5 files changed

+138
-2
lines changed

5 files changed

+138
-2
lines changed

.vscode/launch.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,23 @@
2727
"args": [ ],
2828
"cwd": "${workspaceRoot}",
2929
"stopAtEntry": false
30-
}
30+
},
31+
{
32+
"name": "Debug Sample",
33+
"type": "mono",
34+
"request": "attach",
35+
"preLaunchTask": "run-sample",
36+
"address": "localhost",
37+
"port": 10000
38+
},
39+
{
40+
"name": "Debug Sample Under DotNet",
41+
"type": "mono",
42+
"request": "attach",
43+
"address": "localhost",
44+
"port": 10000,
45+
"preLaunchTask": "run-sample-under-dotnet",
46+
},
3147
],
3248
"inputs": [
3349
{

.vscode/tasks.json

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,55 @@
8686
"problemMatcher": [
8787
"$msCompile"
8888
]
89+
},
90+
{
91+
"label": "build-sample",
92+
"type": "shell",
93+
"command": "bin/${input:configuration}/bin/xabuild ${input:project} /t:${input:target} /p:Configuration=${input:configuration}",
94+
"group": {
95+
"kind": "build",
96+
"isDefault": true
97+
},
98+
"problemMatcher": [
99+
"$msCompile"
100+
]
101+
},
102+
{
103+
"label": "run-sample",
104+
"type": "shell",
105+
"command": "bin/${input:configuration}/bin/xabuild ${input:project} /restore \"/t:Install;_Run\" /p:AndroidAttachDebugger=${input:attach} /p:Configuration=${input:configuration}",
106+
"group": {
107+
"kind": "build",
108+
"isDefault": true
109+
},
110+
"problemMatcher": [
111+
"$msCompile"
112+
]
113+
},
114+
{
115+
"label": "build-sample-under-dotnet",
116+
"type": "shell",
117+
"command": "${env:HOME}/android-toolchain/dotnet/dotnet build ${input:project} -p:Configuration=${input:configuration} -t:${input:target}",
118+
"group": {
119+
"kind": "build",
120+
"isDefault": true
121+
},
122+
"problemMatcher": [
123+
"$msCompile"
124+
]
89125
},
126+
{
127+
"label": "run-sample-under-dotnet",
128+
"type": "shell",
129+
"command": "${env:HOME}/android-toolchain/dotnet/dotnet build ${input:project} \"-t:Run\" --no-restore -p:TargetFramework=${input:targetframework} -p:Configuration=${input:configuration} -p:AndroidAttachDebugger=${input:attach}",
130+
"group": {
131+
"kind": "build",
132+
"isDefault": true
133+
},
134+
"problemMatcher": [
135+
"$msCompile"
136+
]
137+
},
90138
],
91139
"inputs": [
92140
{
@@ -95,6 +143,50 @@
95143
"default": "Debug",
96144
"description": "The Build Configuration",
97145
"options": [ "Debug", "Release"]
98-
}
146+
},
147+
{
148+
"id": "attach",
149+
"type": "pickString",
150+
"default": "Build",
151+
"description": "Attach Debugger?",
152+
"options": [
153+
"true",
154+
"false",
155+
]
156+
},
157+
{
158+
// Add additional projects here. They will be available in the drop down
159+
// in vscode.
160+
"id": "project",
161+
"type": "pickString",
162+
"default": "samples/HelloWorld/HelloWorld.csproj",
163+
"description": "Pick the Project you want to build.",
164+
"options": [
165+
"samples/HelloWorld/HelloWorld.csproj",
166+
"samples/HelloWorld/HelloWorld.DotNet.csproj",
167+
"samples/VSAndroidApp/VSAndroidApp.csproj",
168+
]
169+
},
170+
{
171+
"id": "targetframework",
172+
"type": "pickString",
173+
"default": "Build",
174+
"description": "Select TargetFramework",
175+
"options": [
176+
"net6.0-android",
177+
]
178+
},
179+
{
180+
"id": "target",
181+
"type": "pickString",
182+
"default": "Build",
183+
"description": "Select MSBuild Target to run.",
184+
"options": [
185+
"Build",
186+
"Install",
187+
"SignAndroidPackage",
188+
"Clean"
189+
]
190+
},
99191
]
100192
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net6.0-android</TargetFramework>
4+
<RootNamespace>HelloLibrary</RootNamespace>
5+
</PropertyGroup>
6+
</Project>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net6.0-android</TargetFramework>
4+
<OutputType>Exe</OutputType>
5+
<RootNamespace>HelloWorld</RootNamespace>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<ProjectReference Include="HelloLibrary\HelloLibrary.DotNet.csproj" />
9+
</ItemGroup>
10+
<ItemGroup>
11+
<Compile Remove="Properties\AssemblyInfo.cs" />
12+
<!-- <Compile Remove="Resources\Resource.designer.cs" /> -->
13+
<Compile Remove="HelloLibrary\**\*.cs" />
14+
</ItemGroup>
15+
</Project>

samples/NuGet.config

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<add key="local-xa" value="../bin/BuildDebug/nuget-unsigned" />
5+
</packageSources>
6+
<disabledPackageSources />
7+
</configuration>

0 commit comments

Comments
 (0)