|
4 | 4 | using Microsoft.Build.Evaluation;
|
5 | 5 | using Microsoft.DotNet.Cli.Utils;
|
6 | 6 | using Microsoft.DotNet.Tools;
|
| 7 | +using Microsoft.DotNet.Tools.Common; |
| 8 | +using Microsoft.DotNet.Tools.Test; |
7 | 9 | using NuGet.Packaging;
|
8 | 10 | using LocalizableStrings = Microsoft.DotNet.Tools.Test.LocalizableStrings;
|
9 | 11 |
|
@@ -112,34 +114,51 @@ public static IEnumerable<TestModule> GetProjectProperties(string projectFilePat
|
112 | 114 | // Check if TargetFramework is specified in global properties
|
113 | 115 | if (globalProperties.TryGetValue(ProjectProperties.TargetFramework, out string targetFramework))
|
114 | 116 | {
|
| 117 | + Logger.LogTrace(() => $"Loaded project '{Path.GetFileName(projectFilePath)}' with global property TargetFramework '{targetFramework}'."); |
| 118 | + |
115 | 119 | if (IsValidTargetFramework(project, targetFramework))
|
116 | 120 | {
|
| 121 | + Logger.LogTrace(() => $"Project '{Path.GetFileName(projectFilePath)}' with TargetFramework '{targetFramework}': before re-evaluation '{ProjectProperties.IsTestingPlatformApplication}' is '{project.GetPropertyValue(ProjectProperties.IsTestingPlatformApplication)}'."); |
| 122 | + |
117 | 123 | project.SetProperty(ProjectProperties.TargetFramework, targetFramework);
|
118 | 124 | 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) |
120 | 128 | {
|
121 | 129 | projects.Add(module);
|
122 | 130 | }
|
123 | 131 | }
|
| 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 | + } |
124 | 137 | }
|
125 | 138 | else
|
126 | 139 | {
|
127 | 140 | string targetFrameworks = project.GetPropertyValue(ProjectProperties.TargetFrameworks);
|
128 | 141 |
|
129 | 142 | if (string.IsNullOrEmpty(targetFrameworks))
|
130 | 143 | {
|
| 144 | + Logger.LogTrace(() => $"Loaded project '{Path.GetFileName(projectFilePath)}' has '{ProjectProperties.IsTestingPlatformApplication}' = '{project.GetPropertyValue(ProjectProperties.IsTestingPlatformApplication)}'."); |
| 145 | + |
131 | 146 | if (GetModuleFromProject(project) is {} module)
|
132 | 147 | {
|
133 | 148 | projects.Add(module);
|
134 | 149 | }
|
135 | 150 | }
|
136 | 151 | else
|
137 | 152 | {
|
| 153 | + Logger.LogTrace(() => $"Loaded project '{Path.GetFileName(projectFilePath)}' has '{ProjectProperties.IsTestingPlatformApplication}' = '{project.GetPropertyValue(ProjectProperties.IsTestingPlatformApplication)}' (TFMs: '{targetFrameworks}')."); |
| 154 | + |
138 | 155 | var frameworks = targetFrameworks.Split(CliConstants.SemiColon, StringSplitOptions.RemoveEmptyEntries);
|
139 | 156 | foreach (var framework in frameworks)
|
140 | 157 | {
|
141 | 158 | project.SetProperty(ProjectProperties.TargetFramework, framework);
|
142 | 159 | project.ReevaluateIfNecessary();
|
| 160 | + Logger.LogTrace(() => $"Loaded project '{Path.GetFileName(projectFilePath)}' has '{ProjectProperties.IsTestingPlatformApplication}' = '{project.GetPropertyValue(ProjectProperties.IsTestingPlatformApplication)}' (TFM: '{framework}')."); |
| 161 | + |
143 | 162 | if (GetModuleFromProject(project) is {} module)
|
144 | 163 | {
|
145 | 164 | projects.Add(module);
|
|
0 commit comments