@@ -144,12 +144,39 @@ task Build {
144
144
exec { & $script :dotnetExe build - c $Configuration .\PowerShellEditorServices.sln $script :TargetFrameworksParam }
145
145
}
146
146
147
+ function UploadTestLogs {
148
+ if ($script :IsCIBuild ) {
149
+ $testLogsPath = " $PSScriptRoot /test/PowerShellEditorServices.Test.Host/bin/$Configuration /net451/logs"
150
+ $testLogsZipPath = " $PSScriptRoot /TestLogs.zip"
151
+
152
+ if (Test-Path $testLogsPath ) {
153
+ [System.IO.Compression.ZipFile ]::CreateFromDirectory(
154
+ $testLogsPath ,
155
+ $testLogsZipPath )
156
+
157
+ Push-AppveyorArtifact $testLogsZipPath
158
+ }
159
+ else {
160
+ Write-Host " `n ### WARNING: Test logs could not be found!`n " - ForegroundColor Yellow
161
+ }
162
+ }
163
+ }
164
+
147
165
task Test - If { ! $script :IsUnix } {
148
166
exec { & $script :dotnetExe test - c $Configuration -f net451 .\test\PowerShellEditorServices.Test\PowerShellEditorServices.Test.csproj }
149
167
exec { & $script :dotnetExe test - c $Configuration -f net451 .\test\PowerShellEditorServices.Test.Protocol\PowerShellEditorServices.Test.Protocol.csproj }
150
168
exec { & $script :dotnetExe test - c $Configuration -f net451 .\test\PowerShellEditorServices.Test.Host\PowerShellEditorServices.Test.Host.csproj }
151
169
}
152
170
171
+ task CITest (job Test - Safe), {
172
+ # This task is used to ensure we have a chance to upload
173
+ # test logs as a CI artifact when the tests fail
174
+ if (error Test) {
175
+ UploadTestLogs
176
+ Write-Error " Failing build due to test failure."
177
+ }
178
+ }
179
+
153
180
task LayoutModule - After Build, BuildHost {
154
181
New-Item - Force $PSScriptRoot \module\PowerShellEditorServices\bin\ - Type Directory | Out-Null
155
182
New-Item - Force $PSScriptRoot \module\PowerShellEditorServices\bin\Desktop - Type Directory | Out-Null
@@ -185,21 +212,5 @@ task UploadArtifacts -If ($script:IsCIBuild) {
185
212
}
186
213
}
187
214
188
- task UploadTestLogs - After Test - If ($script :IsCIBuild ) {
189
- $testLogsPath = " $PSScriptRoot /test/PowerShellEditorServices.Test.Host/bin/$Configuration /net451/logs"
190
- $testLogsZipPath = " $PSScriptRoot /TestLogs.zip"
191
-
192
- if (Test-Path $testLogsPath ) {
193
- [System.IO.Compression.ZipFile ]::CreateFromDirectory(
194
- $testLogsPath ,
195
- $testLogsZipPath )
196
-
197
- Push-AppveyorArtifact $testLogsZipPath
198
- }
199
- else {
200
- Write-Host " `n ### WARNING: Test logs could not be found!`n " - ForegroundColor Yellow
201
- }
202
- }
203
-
204
215
# The default task is to run the entire CI build
205
- task . GetProductVersion, Clean , Build, TestPowerShellApi, Test , PackageNuGet, PackageModule, UploadArtifacts
216
+ task . GetProductVersion, Clean , Build, TestPowerShellApi, CITest , PackageNuGet, PackageModule, UploadArtifacts
0 commit comments