@@ -2,8 +2,10 @@ import path = require('path');
2
2
import tl = require( 'azure-pipelines-task-lib/task' ) ;
3
3
import { ToolRunner } from 'azure-pipelines-task-lib/toolrunner' ;
4
4
import msbuildHelpers = require( 'msbuildhelpers/msbuildhelpers' ) ;
5
+ import { TelemetryPayload , emitTelemetry } from './telemetryHelper' ;
5
6
6
7
async function run ( ) {
8
+ const telemetry = { } as TelemetryPayload ;
7
9
try {
8
10
tl . setResourcePath ( path . join ( __dirname , 'task.json' ) ) ;
9
11
@@ -14,6 +16,11 @@ async function run() {
14
16
let msbuildArguments : string = tl . getInput ( 'msbuildArguments' ) ;
15
17
let clean : boolean = tl . getBoolInput ( 'clean' ) ;
16
18
19
+ // pass inputs to telemetry object
20
+ telemetry . configuration = configuration ;
21
+ telemetry . platform = platform ;
22
+ telemetry . msBuildArguments = msbuildArguments ;
23
+
17
24
let logsolutionEvents : boolean = tl . getBoolInput ( 'logsolutionEvents' ) ;
18
25
if ( logsolutionEvents ) {
19
26
tl . warning ( tl . loc ( 'RecordProjectDetailsOnlySupportedOnWindows' ) ) ;
@@ -28,15 +35,17 @@ async function run() {
28
35
if ( ! msbuildLocationMethod ) {
29
36
msbuildLocationMethod = 'version' ;
30
37
}
38
+ telemetry . msBuildLocationMethod = msbuildLocationMethod ;
31
39
32
40
let msbuildTool : string ;
33
41
if ( msbuildLocationMethod === 'version' ) {
34
42
let msbuildVersion : string = tl . getInput ( 'msbuildVersion' ) ;
43
+ telemetry . msBuildVersion = msbuildVersion ;
35
44
msbuildTool = await msbuildHelpers . getMSBuildPath ( msbuildVersion ) ;
36
45
}
37
46
if ( msbuildLocationMethod === 'location' ) {
38
47
msbuildTool = tl . getInput ( 'msbuildLocation' ) ;
39
- }
48
+ }
40
49
41
50
let filesList : string [ ] = tl . findMatch ( null , solution , { followSymbolicLinks : false , followSpecifiedSymbolicLink : false , allowBrokenSymbolicLinks : false } , { matchBase : true } ) ;
42
51
for ( let file of filesList ) {
@@ -59,10 +68,18 @@ async function run() {
59
68
if ( msbuildArguments ) {
60
69
buildTool . line ( msbuildArguments ) ;
61
70
}
71
+
72
+ const startExecTime = new Date ( ) . getTime ( ) ;
62
73
await buildTool . exec ( ) ;
74
+ const endExecTime = new Date ( ) . getTime ( ) ;
75
+
76
+ const executionTime = ( endExecTime - startExecTime ) / 1000 ; // need to convert from milliseconds to seconds
77
+ telemetry . msbuildExectionTimeSeconds = executionTime ;
63
78
}
64
79
} catch ( err ) {
65
80
tl . setResult ( tl . TaskResult . Failed , err ) ;
81
+ } finally {
82
+ emitTelemetry ( telemetry ) ;
66
83
}
67
84
}
68
85
0 commit comments