forked from dotnet/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetTestsProject.cs
46 lines (36 loc) · 1.71 KB
/
GetTestsProject.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
using Microsoft.Build.Framework;
using Microsoft.DotNet.Tools.Test;
namespace Microsoft.NET.Build.Tasks
{
public class GetTestsProject : Microsoft.Build.Utilities.Task
{
[Required]
public ITaskItem TargetPath { get; set; }
[Required]
public ITaskItem GetTestsProjectPipeName { get; set; }
[Required]
public ITaskItem ProjectFullPath { get; set; }
[Required]
public ITaskItem TargetFramework { get; set; }
public override bool Execute()
{
try
{
Log.LogMessage(MessageImportance.Low, $"Target path: {TargetPath}");
NamedPipeClient dotnetTestPipeClient = new(GetTestsProjectPipeName.ItemSpec);
dotnetTestPipeClient.RegisterSerializer(new ModuleMessageSerializer(), typeof(ModuleMessage));
dotnetTestPipeClient.RegisterSerializer(new VoidResponseSerializer(), typeof(VoidResponse));
dotnetTestPipeClient.ConnectAsync(CancellationToken.None).GetAwaiter().GetResult();
dotnetTestPipeClient.RequestReplyAsync<ModuleMessage, VoidResponse>(new ModuleMessage(TargetPath.ItemSpec, ProjectFullPath.ItemSpec, TargetFramework.ItemSpec), CancellationToken.None).GetAwaiter().GetResult();
}
catch (Exception ex)
{
Log.LogErrorFromException(ex);
}
return !Log.HasLoggedErrors;
}
}
}