@@ -52,84 +52,18 @@ if (Get-Command git -ErrorAction SilentlyContinue) {
52
52
git update-index -- assume- unchanged " $PSScriptRoot /src/PowerShellEditorServices.Hosting/BuildInfo.cs"
53
53
}
54
54
55
- function Install-Dotnet {
56
- param (
57
- [string []]$Channel ,
58
- [switch ]$Runtime
59
- )
60
-
61
- $env: DOTNET_INSTALL_DIR = " $PSScriptRoot /.dotnet"
62
-
63
- $components = if ($Runtime ) { " Runtime " } else { " SDK and Runtime " }
64
- $components += $Channel -join ' , '
65
-
66
- Write-Host " Installing .NET $components " - ForegroundColor Green
67
-
68
- # The install script is platform-specific
69
- $installScriptExt = if ($script :IsNix ) { " sh" } else { " ps1" }
70
- $installScript = " dotnet-install.$installScriptExt "
71
-
72
- # Download the official installation script and run it
73
- $installScriptPath = Join-Path ([System.IO.Path ]::GetTempPath()) $installScript
74
- Invoke-WebRequest " https://dot.net/v1/$installScript " - OutFile $installScriptPath
75
-
76
- # Download and install the different .NET channels
77
- foreach ($dotnetChannel in $Channel )
78
- {
79
- if ($script :IsNix ) {
80
- chmod + x $installScriptPath
81
- }
82
-
83
- $params = if ($script :IsNix ) {
84
- @ (' -Channel' , $dotnetChannel , ' -InstallDir' , $env: DOTNET_INSTALL_DIR , ' -NoPath' , ' -Verbose' )
85
- } else {
86
- @ {
87
- Channel = $dotnetChannel
88
- InstallDir = $env: DOTNET_INSTALL_DIR
89
- NoPath = $true
90
- Verbose = $true
91
- }
92
- }
93
-
94
- # Install just the runtime, not the SDK
95
- if ($Runtime ) {
96
- if ($script :IsNix ) { $params += @ (' -Runtime' , ' dotnet' ) }
97
- else { $params [' Runtime' ] = ' dotnet' }
98
- }
99
-
100
- exec { & $installScriptPath @params }
55
+ task FindDotNet {
56
+ assert (Get-Command dotnet - ErrorAction SilentlyContinue) " dotnet not found, please install it: https://aka.ms/dotnet-cli"
57
+ assert ([Version ](dotnet -- version) -ge [Version ](" 6.0" )) " .NET SDK 6.0 or higher is required, please update it: https://aka.ms/dotnet-cli"
58
+
59
+ # Anywhere other than on a Mac with an M1 processor, we additionally
60
+ # need the .NET 3.1 runtime for our netcoreapp3.1 framework.
61
+ if (! $script :IsAppleM1 ) {
62
+ $runtimes = dotnet -- list- runtimes
63
+ assert ($runtimes -match " Microsoft.NETCore.App 3.1" ) " .NET Runtime 3.1 required but not found!"
101
64
}
102
65
103
- $env: PATH = $env: DOTNET_INSTALL_DIR + [System.IO.Path ]::PathSeparator + $env: PATH
104
-
105
- Write-Host ' .NET installation complete' - ForegroundColor Green
106
- }
107
-
108
- task SetupDotNet - Before Clean , Build, TestServerWinPS, TestServerPS7, TestServerPS72, TestE2E {
109
-
110
- $dotnetPath = " $PSScriptRoot /.dotnet"
111
- $dotnetExePath = if ($script :IsNix ) { " $dotnetPath /dotnet" } else { " $dotnetPath /dotnet.exe" }
112
-
113
- if (! (Test-Path $dotnetExePath )) {
114
- # TODO: Test .NET 5 with PowerShell 7.1
115
- #
116
- # We use the .NET 6 SDK, so we always install it and its runtime.
117
- Install-Dotnet - Channel ' 6.0' # SDK and runtime
118
- # Anywhere other than on a Mac with an M1 processor, we additionally
119
- # install the .NET 3.1 and 5.0 runtimes (but not their SDKs).
120
- if (! $script :IsAppleM1 ) { Install-Dotnet - Channel ' 3.1' , ' 5.0' - Runtime }
121
- }
122
-
123
- # This variable is used internally by 'dotnet' to know where it's installed
124
- $script :dotnetExe = Resolve-Path $dotnetExePath
125
- if (! $env: DOTNET_INSTALL_DIR )
126
- {
127
- $dotnetExeDir = [System.IO.Path ]::GetDirectoryName($script :dotnetExe )
128
- $env: PATH = $dotnetExeDir + [System.IO.Path ]::PathSeparator + $env: PATH
129
- $env: DOTNET_INSTALL_DIR = $dotnetExeDir
130
- }
131
-
132
- Write-Host " `n ### Using dotnet v$ ( & $script :dotnetExe -- version) at path $script :dotnetExe `n " - ForegroundColor Green
66
+ Write-Host " Using dotnet v$ ( dotnet -- version) at path $ ( (Get-Command dotnet).Source) " - ForegroundColor Green
133
67
}
134
68
135
69
task BinClean {
@@ -138,9 +72,8 @@ task BinClean {
138
72
Remove-Item $PSScriptRoot \module\PowerShellEditorServices.VSCode\bin - Recurse - Force - ErrorAction Ignore
139
73
}
140
74
141
- task Clean BinClean, {
142
- exec { & $script :dotnetExe restore }
143
- exec { & $script :dotnetExe clean }
75
+ task Clean FindDotNet, BinClean, {
76
+ exec { & dotnet clean }
144
77
Get-ChildItem - Recurse $PSScriptRoot \src\* .nupkg | Remove-Item - Force - ErrorAction Ignore
145
78
Get-ChildItem $PSScriptRoot \PowerShellEditorServices* .zip | Remove-Item - Force - ErrorAction Ignore
146
79
Get-ChildItem $PSScriptRoot \module\PowerShellEditorServices\Commands\en- US\*- help.xml | Remove-Item - Force - ErrorAction Ignore
@@ -155,7 +88,7 @@ task Clean BinClean,{
155
88
}
156
89
}
157
90
158
- task CreateBuildInfo - Before Build {
91
+ task CreateBuildInfo {
159
92
$buildVersion = " <development-build>"
160
93
$buildOrigin = " Development"
161
94
$buildCommit = git rev- parse HEAD
@@ -217,59 +150,55 @@ task SetupHelpForTests {
217
150
Write-Host " Updating help for tests"
218
151
Update-Help - Module Microsoft.PowerShell.Utility - Force - Scope CurrentUser
219
152
}
220
- else
221
- {
222
- Write-Host " Write-Host help found -- Update-Help skipped"
223
- }
224
153
}
225
154
226
- Task Build {
227
- exec { & $ script :dotnetExe publish - c $Configuration .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $ script :NetRuntime .Standard }
228
- exec { & $ script :dotnetExe publish - c $Configuration .\src\PowerShellEditorServices.Hosting \PowerShellEditorServices.Hosting. csproj -f $script :NetRuntime.PS7 }
229
- if ( -not $ script :IsNix )
230
- {
231
- exec { & $ script :dotnetExe publish - c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetRuntime.Desktop }
155
+ Task Build FindDotNet , CreateBuildInfo , {
156
+ exec { & dotnet restore }
157
+ exec { & dotnet publish - c $Configuration .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script :NetRuntime.Standard }
158
+ exec { & dotnet publish - c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $ script :NetRuntime .PS7 }
159
+ if ( -not $ script :IsNix ) {
160
+ exec { & dotnet publish - c $Configuration .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetRuntime.Desktop }
232
161
}
233
162
234
163
# Build PowerShellEditorServices.VSCode module
235
- exec { & $ script :dotnetExe publish - c $Configuration .\src\PowerShellEditorServices.VSCode\PowerShellEditorServices.VSCode.csproj -f $script :NetRuntime.Standard }
164
+ exec { & dotnet publish - c $Configuration .\src\PowerShellEditorServices.VSCode\PowerShellEditorServices.VSCode.csproj -f $script :NetRuntime.Standard }
236
165
}
237
166
238
- task Test SetupHelpForTests , TestServer, TestE2E
167
+ task Test TestServer, TestE2E
239
168
240
- task TestServer TestServerWinPS, TestServerPS7, TestServerPS72
169
+ task TestServer TestServerWinPS, TestServerPS7, TestServerPS72
241
170
242
- task TestServerWinPS - If (-not $script :IsNix ) {
171
+ Task TestServerWinPS - If (-not $script :IsNix ) Build , SetupHelpForTests , {
243
172
Set-Location .\test\PowerShellEditorServices.Test\
244
173
# TODO: See https://github.com/dotnet/sdk/issues/18353 for x64 test host
245
174
# that is debuggable! If architecture is added, the assembly path gets an
246
175
# additional folder, necesstiating fixes to find the commands definition
247
176
# file and test files.
248
- exec { & $ script :dotnetExe $script :dotnetTestArgs $script :NetRuntime.Desktop }
177
+ exec { & dotnet $script :dotnetTestArgs $script :NetRuntime.Desktop }
249
178
}
250
179
251
- task TestServerPS7 - If (-not $script :IsAppleM1 ) {
180
+ task TestServerPS7 - If (-not $script :IsAppleM1 ) Build , SetupHelpForTests , {
252
181
Set-Location .\test\PowerShellEditorServices.Test\
253
- exec { & $ script :dotnetExe $script :dotnetTestArgs $script :NetRuntime.PS7 }
182
+ exec { & dotnet $script :dotnetTestArgs $script :NetRuntime.PS7 }
254
183
}
255
184
256
- task TestServerPS72 {
185
+ task TestServerPS72 Build , SetupHelpForTests , {
257
186
Set-Location .\test\PowerShellEditorServices.Test\
258
- exec { & $ script :dotnetExe $script :dotnetTestArgs $script :NetRuntime.PS72 }
187
+ exec { & dotnet $script :dotnetTestArgs $script :NetRuntime.PS72 }
259
188
}
260
189
261
- task TestE2E {
190
+ task TestE2E Build , SetupHelpForTests , {
262
191
Set-Location .\test\PowerShellEditorServices.Test.E2E\
263
192
264
193
$env: PWSH_EXE_NAME = if ($IsCoreCLR ) { " pwsh" } else { " powershell" }
265
194
$NetRuntime = if ($IsAppleM1 ) { $script :NetRuntime.PS72 } else { $script :NetRuntime.PS7 }
266
- exec { & $ script :dotnetExe $script :dotnetTestArgs $NetRuntime }
195
+ exec { & dotnet $script :dotnetTestArgs $NetRuntime }
267
196
268
197
# Run E2E tests in ConstrainedLanguage mode.
269
198
if (! $script :IsNix ) {
270
199
try {
271
200
[System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , " 0x80000007" , [System.EnvironmentVariableTarget ]::Machine);
272
- exec { & $ script :dotnetExe $script :dotnetTestArgs $script :NetRuntime.PS7 }
201
+ exec { & dotnet $script :dotnetTestArgs $script :NetRuntime.PS7 }
273
202
} finally {
274
203
[System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , $null , [System.EnvironmentVariableTarget ]::Machine);
275
204
}
0 commit comments