Skip to content

Commit 1f8b468

Browse files
committed
Add more logging to dotnet test tracing
1 parent 4708311 commit 1f8b468

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/Cli/dotnet/commands/dotnet-test/SolutionAndProjectUtility.cs

+20-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
using Microsoft.Build.Evaluation;
55
using Microsoft.DotNet.Cli.Utils;
66
using Microsoft.DotNet.Tools;
7+
using Microsoft.DotNet.Tools.Common;
8+
using Microsoft.DotNet.Tools.Test;
79
using NuGet.Packaging;
810
using LocalizableStrings = Microsoft.DotNet.Tools.Test.LocalizableStrings;
911

@@ -112,34 +114,51 @@ public static IEnumerable<TestModule> GetProjectProperties(string projectFilePat
112114
// Check if TargetFramework is specified in global properties
113115
if (globalProperties.TryGetValue(ProjectProperties.TargetFramework, out string targetFramework))
114116
{
117+
Logger.LogTrace(() => $"Loaded project '{Path.GetFileName(projectFilePath)}' with global property TargetFramework '{targetFramework}'.");
118+
115119
if (IsValidTargetFramework(project, targetFramework))
116120
{
121+
Logger.LogTrace(() => $"Project '{Path.GetFileName(projectFilePath)}' with TargetFramework '{targetFramework}': before re-evaluation '{ProjectProperties.IsTestingPlatformApplication}' is '{project.GetPropertyValue(ProjectProperties.IsTestingPlatformApplication)}'.");
122+
117123
project.SetProperty(ProjectProperties.TargetFramework, targetFramework);
118124
project.ReevaluateIfNecessary();
119-
if (GetModuleFromProject(project) is {} module)
125+
Logger.LogTrace(() => $"Project '{Path.GetFileName(projectFilePath)}' with TargetFramework '{targetFramework}': after re-evaluation '{ProjectProperties.IsTestingPlatformApplication}' is '{project.GetPropertyValue(ProjectProperties.IsTestingPlatformApplication)}'.");
126+
127+
if (GetModuleFromProject(project) is { } module)
120128
{
121129
projects.Add(module);
122130
}
123131
}
132+
else
133+
{
134+
// TODO: When can this happen? Should we explicitly error?
135+
Logger.LogTrace(() => $"Project '{Path.GetFileName(projectFilePath)}' with TargetFramework '{targetFramework}' was considered invalid.");
136+
}
124137
}
125138
else
126139
{
127140
string targetFrameworks = project.GetPropertyValue(ProjectProperties.TargetFrameworks);
128141

129142
if (string.IsNullOrEmpty(targetFrameworks))
130143
{
144+
Logger.LogTrace(() => $"Loaded project '{Path.GetFileName(projectFilePath)}' has '{ProjectProperties.IsTestingPlatformApplication}' = '{project.GetPropertyValue(ProjectProperties.IsTestingPlatformApplication)}'.");
145+
131146
if (GetModuleFromProject(project) is {} module)
132147
{
133148
projects.Add(module);
134149
}
135150
}
136151
else
137152
{
153+
Logger.LogTrace(() => $"Loaded project '{Path.GetFileName(projectFilePath)}' has '{ProjectProperties.IsTestingPlatformApplication}' = '{project.GetPropertyValue(ProjectProperties.IsTestingPlatformApplication)}' (TFMs: '{targetFrameworks}').");
154+
138155
var frameworks = targetFrameworks.Split(CliConstants.SemiColon, StringSplitOptions.RemoveEmptyEntries);
139156
foreach (var framework in frameworks)
140157
{
141158
project.SetProperty(ProjectProperties.TargetFramework, framework);
142159
project.ReevaluateIfNecessary();
160+
Logger.LogTrace(() => $"Loaded project '{Path.GetFileName(projectFilePath)}' has '{ProjectProperties.IsTestingPlatformApplication}' = '{project.GetPropertyValue(ProjectProperties.IsTestingPlatformApplication)}' (TFM: '{framework}').");
161+
143162
if (GetModuleFromProject(project) is {} module)
144163
{
145164
projects.Add(module);

0 commit comments

Comments
 (0)