private static void UploadCodeCoverageAttachmentsToNewStore(string folder, VssConnection connection, int buildId, string projectId) { TestLogStore logStore = new TestLogStore(connection, new LogTraceListener()); Dictionary <string, string> files = new Dictionary <string, string>(); foreach (var file in Directory.EnumerateFiles(folder, "*.coverage", SearchOption.AllDirectories)) { if (files.TryGetValue(Path.GetFileName(file), out string something)) { continue; } else { files.Add(Path.GetFileName(file), file); Dictionary <string, string> metaData = new Dictionary <string, string>(); metaData.Add("ModuleName", Path.GetFileName(file)); var attachment = logStore.UploadTestBuildLogAsync(new Guid(projectId), buildId, Microsoft.TeamFoundation.TestManagement.WebApi.TestLogType.Intermediate, file, metaData, null, false, System.Threading.CancellationToken.None).Result; } } foreach (var file in Directory.EnumerateFiles(folder, "*.coveragebuffer", SearchOption.AllDirectories)) { Dictionary <string, string> metaData = new Dictionary <string, string>(); metaData.Add("ModuleName", Path.GetFileName(file)); var attachment = logStore.UploadTestBuildLogAsync(new Guid(projectId), buildId, Microsoft.TeamFoundation.TestManagement.WebApi.TestLogType.Intermediate, file, metaData, null, true, System.Threading.CancellationToken.None).Result; } }
public LogStoreHelper(IClientFactory clientFactory) { _logStore = new TestLogStore(clientFactory.VssConnection, new LogStoreTraceListener()); }
static int Main(string[] args) { var connection = getVssConnection(); ITestLogStore _testLogStore = new TestLogStore(connection, new TaskTraceListener()); Publisher publisher = new Publisher(); Console.WriteLine("\nEnter project Id"); string projectId = Console.ReadLine(); Console.WriteLine("\nEnter run Id"); int runId = int.Parse(Console.ReadLine()); Console.WriteLine("\nProvide path for source:"); string sourcePathForRun = Console.ReadLine(); publisher.UploadRunLevelAttachment(_testLogStore, projectId, runId, sourcePathForRun).Wait(); Console.WriteLine("\nUpload directory run level attachment ..........................."); Console.WriteLine("\nProvide path for source directory:"); string sourcePathForRunDir = Console.ReadLine(); Console.WriteLine("\nProvide path for destination directory:"); string sourcePathForRunDestDir = Console.ReadLine(); publisher.UploadRunDirectoryAttachment(_testLogStore, projectId, runId, sourcePathForRunDir, sourcePathForRunDestDir).Wait(); Console.WriteLine("\n\nUploading result level attachment ................."); Console.WriteLine("\nEnter result Id"); int resultId = int.Parse(Console.ReadLine()); Console.WriteLine("\nProvide path for source:"); string sourcePathForResult = Console.ReadLine(); publisher.UploadResultLevelAttachment(_testLogStore, projectId, runId, resultId, sourcePathForResult).Wait(); Console.WriteLine("\n\n\nDownload logstore ..........................."); Console.WriteLine("\nEnter run Id"); int runIdForDownload = int.Parse(Console.ReadLine()); Console.WriteLine("\nProvide path for source:"); string sourcePathForResultForDownload = Console.ReadLine(); publisher.DownloadAttachment(_testLogStore, projectId, runIdForDownload, 0, 0, sourcePathForResultForDownload).Wait(); Console.WriteLine("\n\n\nUpload logstore build level attachment ..........................."); Console.WriteLine("\nEnter build Id"); int buildId = int.Parse(Console.ReadLine()); Console.WriteLine("\nProvide path for source:"); string sourcePathForResultForBuild = Console.ReadLine(); publisher.UploadBuildLevelAttachment(_testLogStore, projectId, buildId, sourcePathForResultForBuild).Wait(); Console.WriteLine("\nUpload directory build level attachment ..........................."); Console.WriteLine("\nProvide path for source directory:"); string sourcePathForResultForBuildDir = Console.ReadLine(); Console.WriteLine("\nProvide path for destination directory:"); string sourcePathForResultForBuildDestDir = Console.ReadLine(); publisher.UploadBuildDirectoryAttachment(_testLogStore, projectId, buildId, sourcePathForResultForBuildDir, sourcePathForResultForBuildDestDir).Wait(); //Disposing test log store object after use _testLogStore.Dispose(); int end = int.Parse(Console.ReadLine()); return(0); }