@@ -125,18 +125,20 @@ task RestorePsesModules -If (-not (Test-Path "module/PSReadLine") -or -not (Test
125
125
}
126
126
127
127
Task Build FindDotNet, CreateBuildInfo, RestorePsesModules, {
128
- Write-Build DarkGreen " Building PowerShellEditorServices"
128
+ Write-Build DarkGreen ' Building PowerShellEditorServices'
129
129
Invoke-BuildExec { & dotnet publish $script :dotnetBuildArgs ./ src/ PowerShellEditorServices/ PowerShellEditorServices.csproj -f $script :NetFramework.Standard }
130
130
Invoke-BuildExec { & dotnet publish $script :dotnetBuildArgs ./ src/ PowerShellEditorServices.Hosting/ PowerShellEditorServices.Hosting.csproj -f $script :NetFramework.PS74 }
131
131
132
132
if (-not $script :IsNix ) {
133
133
Invoke-BuildExec { & dotnet publish $script :dotnetBuildArgs ./ src/ PowerShellEditorServices.Hosting/ PowerShellEditorServices.Hosting.csproj -f $script :NetFramework.PS51 }
134
134
}
135
+ } - If {
136
+ $Null -eq $script :ChangesDetected -or $true -eq $script :ChangesDetected
135
137
}
136
138
137
139
Task AssembleModule - After Build {
138
- Write-Build DarkGreen " Assembling PowerShellEditorServices module"
139
- $psesOutputPath = " ./module/PowerShellEditorServices"
140
+ Write-Build DarkGreen ' Assembling PowerShellEditorServices module'
141
+ $psesOutputPath = ' ./module/PowerShellEditorServices'
140
142
$psesBinOutputPath = " $psesOutputPath /bin"
141
143
$psesDepsPath = " $psesBinOutputPath /Common"
142
144
$psesCoreHostPath = " $psesBinOutputPath /Core"
@@ -147,8 +149,8 @@ Task AssembleModule -After Build {
147
149
}
148
150
149
151
# Copy documents to module root
150
- foreach ($document in @ (" LICENSE" , " NOTICE.txt" , " README.md" , " SECURITY.md" )) {
151
- Copy-Item - Force - Path $document - Destination " ./module"
152
+ foreach ($document in @ (' LICENSE' , ' NOTICE.txt' , ' README.md' , ' SECURITY.md' )) {
153
+ Copy-Item - Force - Path $document - Destination ' ./module'
152
154
}
153
155
154
156
# Assemble PSES module
@@ -186,13 +188,13 @@ Task AssembleModule -After Build {
186
188
}
187
189
188
190
Task BuildCmdletHelp - After AssembleModule {
189
- Write-Build DarkGreen " Building cmdlet help"
191
+ Write-Build DarkGreen ' Building cmdlet help'
190
192
New-ExternalHelp - Path ./ module/ docs - OutputPath ./ module/ PowerShellEditorServices/ Commands/ en- US - Force
191
193
}
192
194
193
195
Task SetupHelpForTests {
194
- Write-Build DarkMagenta " Updating help (for tests)"
195
- Update-Help - Module Microsoft.PowerShell.Management, Microsoft.PowerShell.Utility - Force - Scope CurrentUser - UICulture en- US
196
+ Write-Build DarkMagenta ' Updating help (for tests)'
197
+ Update-Help - Module Microsoft.PowerShell.Management, Microsoft.PowerShell.Utility - Force - Scope CurrentUser - UICulture en- US
196
198
}
197
199
198
200
Task TestPS74 Build, SetupHelpForTests, {
@@ -210,7 +212,7 @@ Task TestPS51 -If (-not $script:IsNix) Build, SetupHelpForTests, {
210
212
# TODO: See https://github.com/PowerShell/vscode-powershell/issues/3886
211
213
# Inheriting the module path for powershell.exe breaks things!
212
214
$originalModulePath = $env: PSModulePath
213
- $env: PSModulePath = " "
215
+ $env: PSModulePath = ' '
214
216
Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetFramework.PS51 }
215
217
} finally {
216
218
$env: PSModulePath = $originalModulePath
@@ -221,7 +223,7 @@ Task TestPS51 -If (-not $script:IsNix) Build, SetupHelpForTests, {
221
223
# should just be the latest supported framework.
222
224
Task TestE2EPwsh Build, SetupHelpForTests, {
223
225
Set-Location ./ test/ PowerShellEditorServices.Test.E2E/
224
- $env: PWSH_EXE_NAME = " pwsh"
226
+ $env: PWSH_EXE_NAME = ' pwsh'
225
227
Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetFramework.PS74 }
226
228
}
227
229
@@ -240,12 +242,12 @@ Task TestE2EDaily -If (Test-Path $PwshDaily) Build, SetupHelpForTests, {
240
242
241
243
Task TestE2EPowerShell - If (-not $script :IsNix ) Build, SetupHelpForTests, {
242
244
Set-Location ./ test/ PowerShellEditorServices.Test.E2E/
243
- $env: PWSH_EXE_NAME = " powershell"
245
+ $env: PWSH_EXE_NAME = ' powershell'
244
246
try {
245
247
# TODO: See https://github.com/PowerShell/vscode-powershell/issues/3886
246
248
# Inheriting the module path for powershell.exe breaks things!
247
249
$originalModulePath = $env: PSModulePath
248
- $env: PSModulePath = " "
250
+ $env: PSModulePath = ' '
249
251
Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetFramework.PS74 }
250
252
} finally {
251
253
$env: PSModulePath = $originalModulePath
@@ -254,45 +256,62 @@ Task TestE2EPowerShell -If (-not $script:IsNix) Build, SetupHelpForTests, {
254
256
255
257
Task TestE2EPwshCLM - If (-not $script :IsNix ) Build, SetupHelpForTests, {
256
258
Set-Location ./ test/ PowerShellEditorServices.Test.E2E/
257
- $env: PWSH_EXE_NAME = " pwsh"
259
+ $env: PWSH_EXE_NAME = ' pwsh'
258
260
259
- if (-not [Security.Principal.WindowsIdentity ]::GetCurrent().Owner.IsWellKnown(" BuiltInAdministratorsSid" )) {
260
- Write-Build DarkRed " Skipping Constrained Language Mode tests as they must be ran in an elevated process"
261
+ if (-not [Security.Principal.WindowsIdentity ]::GetCurrent().Owner.IsWellKnown(' BuiltInAdministratorsSid' )) {
262
+ Write-Build DarkRed ' Skipping Constrained Language Mode tests as they must be ran in an elevated process'
261
263
return
262
264
}
263
265
264
266
try {
265
- Write-Build DarkGreen " Running end-to-end tests in Constrained Language Mode"
266
- [System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , " 0x80000007" , [System.EnvironmentVariableTarget ]::Machine)
267
+ Write-Build DarkGreen ' Running end-to-end tests in Constrained Language Mode'
268
+ [System.Environment ]::SetEnvironmentVariable(' __PSLockdownPolicy' , ' 0x80000007' , [System.EnvironmentVariableTarget ]::Machine)
267
269
Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetFramework.PS74 }
268
270
} finally {
269
- [System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , $null , [System.EnvironmentVariableTarget ]::Machine)
271
+ [System.Environment ]::SetEnvironmentVariable(' __PSLockdownPolicy' , $null , [System.EnvironmentVariableTarget ]::Machine)
270
272
}
271
273
}
272
274
273
275
Task TestE2EPowerShellCLM - If (-not $script :IsNix ) Build, SetupHelpForTests, {
274
276
Set-Location ./ test/ PowerShellEditorServices.Test.E2E/
275
- $env: PWSH_EXE_NAME = " powershell"
277
+ $env: PWSH_EXE_NAME = ' powershell'
276
278
277
- if (-not [Security.Principal.WindowsIdentity ]::GetCurrent().Owner.IsWellKnown(" BuiltInAdministratorsSid" )) {
278
- Write-Build DarkRed " Skipping Constrained Language Mode tests as they must be ran in an elevated process"
279
+ if (-not [Security.Principal.WindowsIdentity ]::GetCurrent().Owner.IsWellKnown(' BuiltInAdministratorsSid' )) {
280
+ Write-Build DarkRed ' Skipping Constrained Language Mode tests as they must be ran in an elevated process'
279
281
return
280
282
}
281
283
282
284
try {
283
- Write-Build DarkGreen " Running end-to-end tests in Constrained Language Mode"
284
- [System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , " 0x80000007" , [System.EnvironmentVariableTarget ]::Machine)
285
+ Write-Build DarkGreen ' Running end-to-end tests in Constrained Language Mode'
286
+ [System.Environment ]::SetEnvironmentVariable(' __PSLockdownPolicy' , ' 0x80000007' , [System.EnvironmentVariableTarget ]::Machine)
285
287
# TODO: See https://github.com/PowerShell/vscode-powershell/issues/3886
286
288
# Inheriting the module path for powershell.exe breaks things!
287
289
$originalModulePath = $env: PSModulePath
288
- $env: PSModulePath = " "
290
+ $env: PSModulePath = ' '
289
291
Invoke-BuildExec { & dotnet $script :dotnetTestArgs $script :NetFramework.PS74 }
290
292
} finally {
291
- [System.Environment ]::SetEnvironmentVariable(" __PSLockdownPolicy" , $null , [System.EnvironmentVariableTarget ]::Machine)
293
+ [System.Environment ]::SetEnvironmentVariable(' __PSLockdownPolicy' , $null , [System.EnvironmentVariableTarget ]::Machine)
292
294
$env: PSModulePath = $originalModulePath
293
295
}
294
296
}
295
297
298
+ Task BuildIfChanged.Init - Before BuildIfChanged {
299
+ [bool ]$script :ChangesDetected = $false
300
+ }
301
+
302
+ Task BuildIfChanged - Inputs {
303
+ $slash = [IO.Path ]::DirectorySeparatorChar
304
+ Get-ChildItem ./ src - Filter ' *.cs' - Recurse
305
+ | Where-Object FullName -NotLike (' *' + $slash + ' obj' + $slash + ' *' )
306
+ | Where-Object FullName -NotLike (' *' + $slash + ' bin' + $slash + ' *' )
307
+ } - Outputs {
308
+ ' ./src/PowerShellEditorServices/bin/Debug/netstandard2.0/Microsoft.PowerShell.EditorServices.dll'
309
+ ' ./src/PowerShellEditorServices.Hosting/bin/Debug/net8.0/Microsoft.PowerShell.EditorServices.Hosting.dll'
310
+ } - Jobs {
311
+ Write-Build DarkMagenta ' Changes detected, rebuilding'
312
+ $script :ChangesDetected = $true
313
+ }, Build
314
+
296
315
Task Test TestPS74, TestE2EPwsh, TestPS51, TestE2EPowerShell
297
316
298
317
Task TestFull Test, TestE2EDaily, TestE2EPwshCLM, TestE2EPowerShellCLM
0 commit comments