@@ -22,34 +22,36 @@ async function run() {
2222 var resolvedSummaryFile : string = resolvePathToSingleItem ( workingDirectory , summaryFileLocation ) ;
2323 if ( failIfCoverageIsEmpty && await ccUtil . isCodeCoverageFileEmpty ( resolvedSummaryFile , codeCoverageTool ) ) {
2424 throw tl . loc ( 'NoCodeCoverage' ) ;
25- }
26-
27- // Resolve the report directory.
28- // It may contain wildcards allowing the path to change between builds, such as for:
29- // $(System.DefaultWorkingDirectory)\artifacts***$(Configuration)\testresults\coverage
30- var resolvedReportDirectory : string = resolvePathToSingleItem ( workingDirectory , reportDirectory ) ;
25+ } else if ( ! tl . exist ( resolvedSummaryFile ) ) {
26+ tl . warning ( tl . loc ( 'NoCodeCoverage' ) ) ;
27+ } else {
28+ // Resolve the report directory.
29+ // It may contain wildcards allowing the path to change between builds, such as for:
30+ // $(System.DefaultWorkingDirectory)\artifacts***$(Configuration)\testresults\coverage
31+ var resolvedReportDirectory : string = resolvePathToSingleItem ( workingDirectory , reportDirectory ) ;
3132
32- // Get any 'Additional Files' to publish as build artifacts
33- if ( additionalFiles ) {
34- // Does the 'Additional Files' value contain wildcards?
35- if ( containsWildcard ( additionalFiles ) ) {
36- // Resolve matches of the 'Additional Files' pattern
37- var additionalFileMatches : string [ ] = tl . findMatch (
38- workingDirectory ,
39- additionalFiles ,
40- { followSymbolicLinks : false , followSpecifiedSymbolicLink : false } ,
41- { matchBase : true } ) ;
42- tl . debug ( tl . loc ( 'FoundNMatchesForPattern' , additionalFileMatches . length , additionalFiles ) ) ;
33+ // Get any 'Additional Files' to publish as build artifacts
34+ if ( additionalFiles ) {
35+ // Does the 'Additional Files' value contain wildcards?
36+ if ( containsWildcard ( additionalFiles ) ) {
37+ // Resolve matches of the 'Additional Files' pattern
38+ var additionalFileMatches : string [ ] = tl . findMatch (
39+ workingDirectory ,
40+ additionalFiles ,
41+ { followSymbolicLinks : false , followSpecifiedSymbolicLink : false } ,
42+ { matchBase : true } ) ;
43+ tl . debug ( tl . loc ( 'FoundNMatchesForPattern' , additionalFileMatches . length , additionalFiles ) ) ;
44+ }
45+ else {
46+ // Use the specific additional file (no wildcards)
47+ var additionalFileMatches : string [ ] = [ additionalFiles ] ;
48+ }
4349 }
44- else {
45- // Use the specific additional file (no wildcards)
46- var additionalFileMatches : string [ ] = [ additionalFiles ] ;
47- }
48- }
4950
50- // Publish code coverage data
51- var ccPublisher = new tl . CodeCoveragePublisher ( ) ;
52- ccPublisher . publish ( codeCoverageTool , resolvedSummaryFile , resolvedReportDirectory , additionalFileMatches ) ;
51+ // Publish code coverage data
52+ var ccPublisher = new tl . CodeCoveragePublisher ( ) ;
53+ ccPublisher . publish ( codeCoverageTool , resolvedSummaryFile , resolvedReportDirectory , additionalFileMatches ) ;
54+ }
5355 }
5456 catch ( err ) {
5557 tl . setResult ( tl . TaskResult . Failed , err ) ;
0 commit comments