public static void PublishTestResults(ICakeContext ctx) { IAzurePipelinesProvider azurePipelines = ctx.AzurePipelines(); if (!azurePipelines.IsRunningOnAzurePipelines || !azurePipelines.IsRunningOnAzurePipelinesHosted) { return; } FilePathCollection trxFiles = ctx.GetFiles("./**/*.trx"); if (trxFiles.Count == 0) { return; } int index = 0; foreach (FilePath trxFile in trxFiles) { string sourceFile = trxFile.FullPath; string directory = IO.Path.GetDirectoryName(sourceFile); string renamedFile = IO.Path.Combine(directory, $"TestResults{index}.trx"); IO.File.Move(sourceFile, renamedFile); index++; } FilePathCollection testResultsFiles = ctx.GetFiles("./**/*.trx"); foreach (FilePath filePath in testResultsFiles) { ctx.Log.Information(filePath.ToString()); } azurePipelines.Commands.PublishTestResults(new AzurePipelinesPublishTestResultsData { TestRunner = AzurePipelinesTestRunnerType.VSTest, TestResultsFiles = testResultsFiles.ToList(), MergeTestResults = true, }); }