-
Notifications
You must be signed in to change notification settings - Fork 10
/
GenerateVSCodeLaunchConfig.ps1
64 lines (54 loc) · 2.47 KB
/
GenerateVSCodeLaunchConfig.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Param (
[Parameter(HelpMessage = "Disables suppressing changes to the ./.vscode/launch.json file in git, allowing changes to be committed.")]
[switch]$allowGitChanges = $false
)
function CreateVsCodeLaunchConfigJson {
param (
[string]$projectName
)
return "{
`"name`": `"$projectName`",
`"type`": `"coreclr`",
`"request`": `"launch`",
`"program`": `"dotnet`",
`"args`": [
`"run`",
`"build`",
`"/r`",
`"/p:UnoSourceGeneratorUseGenerationHost=true`",
`"/p:UnoSourceGeneratorUseGenerationController=false`",
`"/p:UnoRemoteControlPort=443`",
`"--project=`$`{workspaceFolder`}/components/$projectName/heads/Wasm/$projectName.Wasm.csproj`"
],
`"presentation`": {
`"group`": `"2`"
},
`"cwd`": `"`$`{workspaceFolder`}/components/$projectName/heads/Wasm`"
}";
}
$launchConfigJson = Get-Content -Path "$PSScriptRoot/../.vscode/launch.json" -ErrorAction Stop;
$launchConfig = $launchConfigJson | ConvertFrom-Json;
# Remove all non-generated configurations
$originalConfigurations = $launchConfig.configurations;
$launchConfig.configurations = @();
$launchConfig.configurations += $originalConfigurations[0];
$launchConfig.configurations += $originalConfigurations[1];
& $PSScriptRoot/MultiTarget/GenerateAllProjectReferences.ps1 -MultiTarget 'wasm'
foreach ($projectPath in Get-ChildItem -Directory -Depth 0 -Path "$PSScriptRoot/../components/*") {
$projectName = [System.IO.Path]::GetFileNameWithoutExtension($projectPath);
Write-Host "Generating VSCode launch config for $projectName";
$configJson = CreateVsCodeLaunchConfigJson $projectName;
$config = $configJson | ConvertFrom-Json;
$launchConfig.configurations += $config;
}
if ($allowGitChanges.IsPresent) {
Write-Warning "Changes to the default launch.json can now be committed. Run this command again without the -allowGitChanges flag to disable committing further changes.";
git update-index --no-assume-unchanged $PSScriptRoot/../.vscode/launch.json
}
else {
Write-Output "Changes to the default launch.json are now suppressed. To switch branches, run git reset --hard with a clean working tree. Include the -allowGitChanges flag to enable committing changes.";
git update-index --assume-unchanged $PSScriptRoot/../.vscode/launch.json
}
# Save
Set-Content -Path "$PSScriptRoot/../.vscode/launch.json" -Value ($launchConfig | ConvertTo-Json -Depth 9);
Write-Output "Saved VSCode launch configs to $(Resolve-Path $PSScriptRoot/../.vscode/launch.json)";