@@ -2,8 +2,10 @@ import path = require('path');
22import tl = require( 'azure-pipelines-task-lib/task' ) ;
33import { ToolRunner } from 'azure-pipelines-task-lib/toolrunner' ;
44import msbuildHelpers = require( 'msbuildhelpers/msbuildhelpers' ) ;
5+ import { TelemetryPayload , emitTelemetry } from './telemetryHelper' ;
56
67async function run ( ) {
8+ const telemetry = { } as TelemetryPayload ;
79 try {
810 tl . setResourcePath ( path . join ( __dirname , 'task.json' ) ) ;
911
@@ -14,6 +16,11 @@ async function run() {
1416 let msbuildArguments : string = tl . getInput ( 'msbuildArguments' ) ;
1517 let clean : boolean = tl . getBoolInput ( 'clean' ) ;
1618
19+ // pass inputs to telemetry object
20+ telemetry . configuration = configuration ;
21+ telemetry . platform = platform ;
22+ telemetry . msBuildArguments = msbuildArguments ;
23+
1724 let logsolutionEvents : boolean = tl . getBoolInput ( 'logsolutionEvents' ) ;
1825 if ( logsolutionEvents ) {
1926 tl . warning ( tl . loc ( 'RecordProjectDetailsOnlySupportedOnWindows' ) ) ;
@@ -28,15 +35,17 @@ async function run() {
2835 if ( ! msbuildLocationMethod ) {
2936 msbuildLocationMethod = 'version' ;
3037 }
38+ telemetry . msBuildLocationMethod = msbuildLocationMethod ;
3139
3240 let msbuildTool : string ;
3341 if ( msbuildLocationMethod === 'version' ) {
3442 let msbuildVersion : string = tl . getInput ( 'msbuildVersion' ) ;
43+ telemetry . msBuildVersion = msbuildVersion ;
3544 msbuildTool = await msbuildHelpers . getMSBuildPath ( msbuildVersion ) ;
3645 }
3746 if ( msbuildLocationMethod === 'location' ) {
3847 msbuildTool = tl . getInput ( 'msbuildLocation' ) ;
39- }
48+ }
4049
4150 let filesList : string [ ] = tl . findMatch ( null , solution , { followSymbolicLinks : false , followSpecifiedSymbolicLink : false , allowBrokenSymbolicLinks : false } , { matchBase : true } ) ;
4251 for ( let file of filesList ) {
@@ -59,10 +68,18 @@ async function run() {
5968 if ( msbuildArguments ) {
6069 buildTool . line ( msbuildArguments ) ;
6170 }
71+
72+ const startExecTime = new Date ( ) . getTime ( ) ;
6273 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 ;
6378 }
6479 } catch ( err ) {
6580 tl . setResult ( tl . TaskResult . Failed , err ) ;
81+ } finally {
82+ emitTelemetry ( telemetry ) ;
6683 }
6784}
6885
0 commit comments