Skip to content

Commit 364c7e3

Browse files
committed
Added vscode launch config generator
1 parent 9ec3856 commit 364c7e3

File tree

4 files changed

+118
-1
lines changed

4 files changed

+118
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,4 +397,5 @@ FodyWeavers.xsd
397397
# JetBrains Rider
398398
*.sln.iml
399399

400-
launchSettings.json
400+
launchSettings.json
401+
!TreeHouse.code-workspace

.vscode/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
launch.json
2+
tasks.json
3+
!.gitignore

LaunchSettingsGen.targets

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<Project DefaultTargets="Build">
2+
<ItemGroup>
3+
<ProjectFiles Include="*/*.csproj" />
4+
</ItemGroup>
5+
<PropertyGroup>
6+
<LaunchOutput>./.vscode/launch.json</LaunchOutput>
7+
<TasksOutput>./.vscode/tasks.json</TasksOutput>
8+
<LaunchTemlate>
9+
{
10+
"name": "Launch PROJECT_NAME",
11+
"type": "coreclr",
12+
"request": "launch",
13+
"preLaunchTask": "Build PROJECT_NAME",
14+
"program": "OUTPUT_DLL",
15+
"args": [],
16+
"cwd": "OUTPUT_FOLDER",
17+
"console": "internalConsole",
18+
"stopAtEntry": false
19+
},
20+
</LaunchTemlate>
21+
<TaskTemplate>
22+
{
23+
"label": "Build PROJECT_NAME",
24+
"command": "dotnet",
25+
"type": "process",
26+
"args": [
27+
"build",
28+
"PROJECT_FILE",
29+
"/property:GenerateFullPaths=true",
30+
"/consoleloggerparameters:NoSummary;ForceNoAlign"
31+
],
32+
"problemMatcher": "$msCompile"
33+
},
34+
</TaskTemplate>
35+
</PropertyGroup>
36+
<Target Name="SetItemsMetadata" Inputs="@(ProjectFiles)" Outputs="%(Identity).DoesNotExist">
37+
<MSBuild Projects="%(ProjectFiles.Identity)" Targets="GetTargetPath">
38+
<Output TaskParameter="TargetOutputs" PropertyName="ProjectOutputPath" />
39+
</MSBuild>
40+
<PropertyGroup>
41+
<ProjectOutputFolder>$([System.IO.Path]::GetDirectoryName($(ProjectOutputPath)))</ProjectOutputFolder>
42+
<ProjectOutputPath>$(ProjectOutputPath.Replace('\', '\\'))</ProjectOutputPath>
43+
<ProjectOutputFolder>$(ProjectOutputFolder.Replace('\', '\\'))</ProjectOutputFolder>
44+
</PropertyGroup>
45+
<ItemGroup>
46+
<ProjectFiles Condition="'%(Identity)' == '%(ProjectFiles.Identity)'">
47+
<LaunchItem>$(
48+
LaunchTemlate
49+
.Replace("PROJECT_NAME", %(Filename))
50+
.Replace("OUTPUT_DLL", $(ProjectOutputPath))
51+
.Replace("OUTPUT_FOLDER", $(ProjectOutputFolder))
52+
)
53+
</LaunchItem>
54+
<TaskItem>$(
55+
TaskTemplate
56+
.Replace("PROJECT_NAME", %(Filename))
57+
.Replace("PROJECT_FILE", $([System.String]::Copy('%(FullPath)').Replace('\', '\\')))
58+
)
59+
</TaskItem>
60+
</ProjectFiles>
61+
</ItemGroup>
62+
</Target>
63+
<Target Name="Build" DependsOnTargets="SetItemsMetadata" Inputs="@(ProjectFiles)" Outputs="$(LaunchOutput);$(TasksOutput)">
64+
<PropertyGroup>
65+
<LaunchContent>
66+
{
67+
"version": "0.2.0",
68+
"configurations": [
69+
@(ProjectFiles->'%(LaunchItem)', '')
70+
{
71+
"name": "Attach",
72+
"type": "coreclr",
73+
"request": "attach"
74+
}
75+
]
76+
}
77+
</LaunchContent>
78+
<TasksContent>
79+
{
80+
"version": "2.0.0",
81+
"tasks": [
82+
@(ProjectFiles->'%(TaskItem)', '')
83+
]
84+
}
85+
</TasksContent>
86+
</PropertyGroup>
87+
88+
<WriteLinesToFile File="$(LaunchOutput)" Lines="$(LaunchContent)" Overwrite="true" />
89+
<WriteLinesToFile File="$(TasksOutput)" Lines="$(TasksContent)" Overwrite="true" />
90+
</Target>
91+
</Project>

TreeHouse.code-workspace

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"folders": [
3+
{
4+
"path": ".",
5+
}
6+
],
7+
"tasks": {
8+
"version": "2.0.0",
9+
"tasks": [
10+
{
11+
"label": "Generate Launch Configuration",
12+
"command": "dotnet",
13+
"type": "process",
14+
"args": [
15+
"build",
16+
"LaunchSettingsGen.targets",
17+
],
18+
"problemMatcher": "$msCompile"
19+
}
20+
]
21+
}
22+
}

0 commit comments

Comments
 (0)