-
Notifications
You must be signed in to change notification settings - Fork 0
/
LaunchSettingsGen.targets
91 lines (90 loc) · 3.23 KB
/
LaunchSettingsGen.targets
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
<Project DefaultTargets="Build">
<ItemGroup>
<ProjectFiles Include="*/*.csproj" />
</ItemGroup>
<PropertyGroup>
<LaunchOutput>./.vscode/launch.json</LaunchOutput>
<TasksOutput>./.vscode/tasks.json</TasksOutput>
<LaunchTemlate>
{
"name": "Launch PROJECT_NAME",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "Build PROJECT_NAME",
"program": "OUTPUT_DLL",
"args": [],
"cwd": "OUTPUT_FOLDER",
"console": "internalConsole",
"stopAtEntry": false
},
</LaunchTemlate>
<TaskTemplate>
{
"label": "Build PROJECT_NAME",
"command": "dotnet",
"type": "process",
"args": [
"build",
"PROJECT_FILE",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
"problemMatcher": "$msCompile"
},
</TaskTemplate>
</PropertyGroup>
<Target Name="SetItemsMetadata" Inputs="@(ProjectFiles)" Outputs="%(Identity).DoesNotExist">
<MSBuild Projects="%(ProjectFiles.Identity)" Targets="GetTargetPath">
<Output TaskParameter="TargetOutputs" PropertyName="ProjectOutputPath" />
</MSBuild>
<PropertyGroup>
<ProjectOutputFolder>$([System.IO.Path]::GetDirectoryName($(ProjectOutputPath)))</ProjectOutputFolder>
<ProjectOutputPath>$(ProjectOutputPath.Replace('\', '\\'))</ProjectOutputPath>
<ProjectOutputFolder>$(ProjectOutputFolder.Replace('\', '\\'))</ProjectOutputFolder>
</PropertyGroup>
<ItemGroup>
<ProjectFiles Condition="'%(Identity)' == '%(ProjectFiles.Identity)'">
<LaunchItem>$(
LaunchTemlate
.Replace("PROJECT_NAME", %(Filename))
.Replace("OUTPUT_DLL", $(ProjectOutputPath))
.Replace("OUTPUT_FOLDER", $(ProjectOutputFolder))
)
</LaunchItem>
<TaskItem>$(
TaskTemplate
.Replace("PROJECT_NAME", %(Filename))
.Replace("PROJECT_FILE", $([System.String]::Copy('%(FullPath)').Replace('\', '\\')))
)
</TaskItem>
</ProjectFiles>
</ItemGroup>
</Target>
<Target Name="Build" DependsOnTargets="SetItemsMetadata" Inputs="@(ProjectFiles)" Outputs="$(LaunchOutput);$(TasksOutput)">
<PropertyGroup>
<LaunchContent>
{
"version": "0.2.0",
"configurations": [
@(ProjectFiles->'%(LaunchItem)', '')
{
"name": "Attach",
"type": "coreclr",
"request": "attach"
}
]
}
</LaunchContent>
<TasksContent>
{
"version": "2.0.0",
"tasks": [
@(ProjectFiles->'%(TaskItem)', '')
]
}
</TasksContent>
</PropertyGroup>
<WriteLinesToFile File="$(LaunchOutput)" Lines="$(LaunchContent)" Overwrite="true" />
<WriteLinesToFile File="$(TasksOutput)" Lines="$(TasksContent)" Overwrite="true" />
</Target>
</Project>