15
15
function Update-SwiftBuildAndPackageArguments {
16
16
param (
17
17
[string ]$jsonFilePath = " ./assets/test/.vscode/settings.json" ,
18
+ [string ]$codeWorkspaceFilePath = " ./assets/test.code-workspace" ,
18
19
[string ]$windowsSdkVersion = " 10.0.22000.0" ,
19
20
[string ]$vcToolsVersion = " 14.43.34808"
20
21
)
@@ -28,9 +29,17 @@ function Update-SwiftBuildAndPackageArguments {
28
29
exit 1
29
30
}
30
31
32
+ try {
33
+ $codeWorkspaceContent = Get-Content - Raw - Path $codeWorkspaceFilePath | ConvertFrom-Json
34
+ } catch {
35
+ Write-Host " Invalid JSON content in $codeWorkspaceFilePath "
36
+ exit 1
37
+ }
38
+
31
39
if ($jsonContent.PSObject.Properties [' swift.buildArguments' ]) {
32
40
$jsonContent.PSObject.Properties.Remove (' swift.buildArguments' )
33
41
}
42
+
34
43
35
44
$jsonContent | Add-Member - MemberType NoteProperty - Name " swift.buildArguments" - Value @ (
36
45
" -Xbuild-tools-swiftc" , " -windows-sdk-root" , " -Xbuild-tools-swiftc" , $windowsSdkRoot ,
@@ -54,10 +63,20 @@ function Update-SwiftBuildAndPackageArguments {
54
63
" -Xswiftc" , " -visualc-tools-version" , " -Xswiftc" , $vcToolsVersion
55
64
)
56
65
66
+
67
+ $codeWorkspaceContent.PSObject.Properties.Remove (' settings' )
68
+ $codeWorkspaceContent | Add-Member - MemberType NoteProperty - Name " settings" - Value $jsonContent
69
+
57
70
$jsonContent | ConvertTo-Json - Depth 32 | Set-Content - Path $jsonFilePath
58
71
72
+
73
+ $codeWorkspaceContent | ConvertTo-Json - Depth 32 | Set-Content - Path $codeWorkspaceFilePath
74
+
59
75
Write-Host " Contents of ${jsonFilePath} :"
60
76
Get-Content - Path $jsonFilePath
77
+
78
+ Write-Host " Contents of ${codeWorkspaceFilePath} :"
79
+ Get-Content - Path $codeWorkspaceFilePath
61
80
}
62
81
63
82
$swiftVersionOutput = & swift -- version
0 commit comments