@@ -48,17 +48,18 @@ $script:IsArm64 = -not $script:IsNix -and @("ARM64") -contains $env:PROCESSOR_AR
48
48
$script :BuildInfoPath = [System.IO.Path ]::Combine($PSScriptRoot , " src" , " PowerShellEditorServices.Hosting" , " BuildInfo.cs" )
49
49
$script :PsesCommonProps = [xml ](Get-Content - Raw " $PSScriptRoot /PowerShellEditorServices.Common.props" )
50
50
51
- $script :NetRuntime = @ {
51
+ $script :NetFramework = @ {
52
+ PS51 = ' net462'
52
53
PS72 = ' net6.0'
53
54
PS73 = ' net7.0'
54
- Desktop = ' net462 '
55
+ PS74 = ' net8.0 '
55
56
Standard = ' netstandard2.0'
56
57
}
57
58
58
- $script :HostCoreOutput = " $PSScriptRoot /src/PowerShellEditorServices.Hosting/bin/$Configuration /$ ( $script :NetRuntime .PS72 ) /publish"
59
- $script :HostDeskOutput = " $PSScriptRoot /src/PowerShellEditorServices.Hosting/bin/$Configuration /$ ( $script :NetRuntime .Desktop ) /publish"
60
- $script :PsesOutput = " $PSScriptRoot /src/PowerShellEditorServices/bin/$Configuration /$ ( $script :NetRuntime .Standard ) /publish"
61
- $script :VSCodeOutput = " $PSScriptRoot /src/PowerShellEditorServices.VSCode/bin/$Configuration /$ ( $script :NetRuntime .Standard ) /publish"
59
+ $script :HostCoreOutput = " $PSScriptRoot /src/PowerShellEditorServices.Hosting/bin/$Configuration /$ ( $script :NetFramework .PS72 ) /publish"
60
+ $script :HostDeskOutput = " $PSScriptRoot /src/PowerShellEditorServices.Hosting/bin/$Configuration /$ ( $script :NetFramework .PS51 ) /publish"
61
+ $script :PsesOutput = " $PSScriptRoot /src/PowerShellEditorServices/bin/$Configuration /$ ( $script :NetFramework .Standard ) /publish"
62
+ $script :VSCodeOutput = " $PSScriptRoot /src/PowerShellEditorServices.VSCode/bin/$Configuration /$ ( $script :NetFramework .Standard ) /publish"
62
63
63
64
if (Get-Command git - ErrorAction SilentlyContinue) {
64
65
# ignore changes to this file
@@ -157,63 +158,103 @@ namespace Microsoft.PowerShell.EditorServices.Hosting
157
158
}
158
159
159
160
Task SetupHelpForTests {
160
- if (-not (Get-Help Microsoft.PowerShell.Management\Get-Process ).Description) {
161
- Write-Host " Updating help for tests."
162
- Update-Help - Module Microsoft.PowerShell.Management, Microsoft.PowerShell.Utility - Force - Scope CurrentUser
163
- }
161
+ # TODO: Check if it must be updated in a compatible way!
162
+ Write-Host " Updating help for tests."
163
+ Update-Help - Module Microsoft.PowerShell.Management, Microsoft.PowerShell.Utility - Force - Scope CurrentUser
164
164
}
165
165
166
166
Task Build FindDotNet, CreateBuildInfo, {
167
- Invoke-BuildExec { & dotnet publish $script :dotnetBuildArgs .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script :NetRuntime .Standard }
168
- Invoke-BuildExec { & dotnet publish $script :dotnetBuildArgs .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetRuntime .PS72 }
167
+ Invoke-BuildExec { & dotnet publish $script :dotnetBuildArgs .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -f $script :NetFramework .Standard }
168
+ Invoke-BuildExec { & dotnet publish $script :dotnetBuildArgs .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetFramework .PS72 }
169
169
170
170
if (-not $script :IsNix ) {
171
- Invoke-BuildExec { & dotnet publish $script :dotnetBuildArgs .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetRuntime .Desktop }
171
+ Invoke-BuildExec { & dotnet publish $script :dotnetBuildArgs .\src\PowerShellEditorServices.Hosting\PowerShellEditorServices.Hosting.csproj -f $script :NetFramework .PS51 }
172
172
}
173
173
174
174
# Build PowerShellEditorServices.VSCode module
175
- Invoke-BuildExec { & dotnet publish $script :dotnetBuildArgs .\src\PowerShellEditorServices.VSCode\PowerShellEditorServices.VSCode.csproj -f $script :NetRuntime .Standard }
175
+ Invoke-BuildExec { & dotnet publish $script :dotnetBuildArgs .\src\PowerShellEditorServices.VSCode\PowerShellEditorServices.VSCode.csproj -f $script :NetFramework .Standard }
176
176
}
177
177
178
- Task Test TestServer, TestE2E, TestConstrainedLanguageMode
178
+ # The concise set of tests (for pull requests)
179
+ Task Test TestPS74, TestE2EPwsh, TestPS51, TestE2EPowerShell
179
180
180
- Task TestServer SetupHelpForTests, TestServerWinPS, TestServerPS72, TestServerPS73
181
+ # Every combination of tests (for main branch)
182
+ Task TestFull Test, TestPS73, TestPS72, TestE2EPwshCLM, TestE2EPowerShellCLM
181
183
182
- Task TestE2E SetupHelpForTests, TestE2EPwsh, TestE2EWinPS
184
+ Task TestPS74 Build, SetupHelpForTests, {
185
+ Set-Location .\test\PowerShellEditorServices.Test\
186
+ Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetFramework.PS74 }
187
+ }
183
188
184
- Task TestServerWinPS - If ( -not $ script :IsNix ) Build, {
189
+ Task TestPS73 Build, SetupHelpForTests , {
185
190
Set-Location .\test\PowerShellEditorServices.Test\
186
- # TODO: See https://github.com/dotnet/sdk/issues/18353 for x64 test host
187
- # that is debuggable! If architecture is added, the assembly path gets an
188
- # additional folder, necesstiating fixes to find the commands definition
189
- # file and test files.
190
- Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetRuntime.Desktop }
191
+ Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetFramework.PS73 }
191
192
}
192
193
193
- Task TestServerPS72 Build, {
194
+ Task TestPS72 Build, SetupHelpForTests , {
194
195
Set-Location .\test\PowerShellEditorServices.Test\
195
- Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetRuntime .PS72 }
196
+ Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetFramework .PS72 }
196
197
}
197
198
198
- Task TestServerPS73 Build, {
199
+ Task TestPS51 - If ( -not $ script :IsNix ) Build, SetupHelpForTests , {
199
200
Set-Location .\test\PowerShellEditorServices.Test\
200
- Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetRuntime.PS73 }
201
+ # TODO: See https://github.com/dotnet/sdk/issues/18353 for x64 test host
202
+ # that is debuggable! If architecture is added, the assembly path gets an
203
+ # additional folder, necessitating fixes to find the commands definition
204
+ # file and test files.
205
+ try {
206
+ # TODO: See https://github.com/PowerShell/vscode-powershell/issues/3886
207
+ # Inheriting the module path for powershell.exe breaks things!
208
+ $originalModulePath = $env: PSModulePath
209
+ $env: PSModulePath = " "
210
+ Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetFramework.PS51 }
211
+ } finally {
212
+ $env: PSModulePath = $originalModulePath
213
+ }
201
214
}
202
215
203
- Task TestE2EPwsh Build, {
216
+ # NOTE: The framework for the E2E tests applies to the mock client, and so
217
+ # should just be the latest supported framework.
218
+ Task TestE2EPwsh Build, SetupHelpForTests, {
204
219
Set-Location .\test\PowerShellEditorServices.Test.E2E\
205
220
$env: PWSH_EXE_NAME = " pwsh"
206
- Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetRuntime .PS73 }
221
+ Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetFramework .PS74 }
207
222
}
208
223
209
- Task TestE2EWinPS - If (-not $script :IsNix ) Build, {
224
+ Task TestE2EPowerShell - If (-not $script :IsNix ) Build, SetupHelpForTests , {
210
225
Set-Location .\test\PowerShellEditorServices.Test.E2E\
211
226
$env: PWSH_EXE_NAME = " powershell"
212
- Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetRuntime.PS73 }
227
+ try {
228
+ # TODO: See https://github.com/PowerShell/vscode-powershell/issues/3886
229
+ # Inheriting the module path for powershell.exe breaks things!
230
+ $originalModulePath = $env: PSModulePath
231
+ Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetFramework.PS74 }
232
+ } finally {
233
+ $env: PSModulePath = $originalModulePath
234
+ }
235
+ }
236
+
237
+ Task TestE2EPwshCLM - If (-not $script :IsNix ) Build, SetupHelpForTests, {
238
+ Set-Location .\test\PowerShellEditorServices.Test.E2E\
239
+ $env: PWSH_EXE_NAME = " pwsh"
240
+
241
+ if (-not [Security.Principal.WindowsIdentity ]::GetCurrent().Owner.IsWellKnown(" BuiltInAdministratorsSid" )) {
242
+ Write-Warning " Skipping Constrained Language Mode tests as they must be ran in an elevated process."
243
+ return
244
+ }
245
+
246
+ try {
247
+ Write-Host " Running end-to-end tests in Constrained Language Mode."
248
+ [System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , " 0x80000007" , [System.EnvironmentVariableTarget ]::Machine)
249
+ Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetFramework.PS74 }
250
+ } finally {
251
+ [System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , $null , [System.EnvironmentVariableTarget ]::Machine)
252
+ }
213
253
}
214
254
215
- Task TestConstrainedLanguageMode - If (-not $script :IsNix ) Build, {
255
+ Task TestE2EPowerShellCLM - If (-not $script :IsNix ) Build, SetupHelpForTests , {
216
256
Set-Location .\test\PowerShellEditorServices.Test.E2E\
257
+ $env: PWSH_EXE_NAME = " powershell"
217
258
218
259
if (-not [Security.Principal.WindowsIdentity ]::GetCurrent().Owner.IsWellKnown(" BuiltInAdministratorsSid" )) {
219
260
Write-Warning " Skipping Constrained Language Mode tests as they must be ran in an elevated process."
@@ -223,9 +264,13 @@ Task TestConstrainedLanguageMode -If (-not $script:IsNix) Build, {
223
264
try {
224
265
Write-Host " Running end-to-end tests in Constrained Language Mode."
225
266
[System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , " 0x80000007" , [System.EnvironmentVariableTarget ]::Machine)
226
- Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetRuntime.PS73 }
267
+ # TODO: See https://github.com/PowerShell/vscode-powershell/issues/3886
268
+ # Inheriting the module path for powershell.exe breaks things!
269
+ $originalModulePath = $env: PSModulePath
270
+ Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetFramework.PS74 }
227
271
} finally {
228
272
[System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , $null , [System.EnvironmentVariableTarget ]::Machine)
273
+ $env: PSModulePath = $originalModulePath
229
274
}
230
275
}
231
276
0 commit comments