Skip to content

Commit e112eec

Browse files
enable binlog in dotnet test for projects eval (#49643)
1 parent 1e96b3e commit e112eec

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/Cli/dotnet/Commands/Test/MSBuildUtility.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ namespace Microsoft.DotNet.Cli.Commands.Test;
1515

1616
internal static class MSBuildUtility
1717
{
18+
private const string dotnetTestVerb = "dotnet-test";
19+
1820
public static (IEnumerable<ParallelizableTestModuleGroupWithSequentialInnerModules> Projects, bool IsBuiltOrRestored) GetProjectsFromSolution(string solutionFilePath, BuildOptions buildOptions)
1921
{
2022
SolutionModel solutionModel = SlnFileFactory.CreateFromFileOrDirectory(solutionFilePath, includeSolutionFilterFiles: true, includeSolutionXmlFiles: true);
@@ -30,9 +32,11 @@ public static (IEnumerable<ParallelizableTestModuleGroupWithSequentialInnerModul
3032
Path.GetDirectoryName(solutionModel.Description)! :
3133
SolutionAndProjectUtility.GetRootDirectory(solutionFilePath);
3234

33-
var collection = new ProjectCollection(globalProperties: CommonRunHelpers.GetGlobalPropertiesFromArgs([.. buildOptions.MSBuildArgs]), null, toolsetDefinitionLocations: ToolsetDefinitionLocations.Default);
35+
FacadeLogger? logger = LoggerUtility.DetermineBinlogger([.. buildOptions.MSBuildArgs], dotnetTestVerb);
36+
var collection = new ProjectCollection(globalProperties: CommonRunHelpers.GetGlobalPropertiesFromArgs([.. buildOptions.MSBuildArgs]), loggers: logger is null ? null : [logger], toolsetDefinitionLocations: ToolsetDefinitionLocations.Default);
3437

3538
ConcurrentBag<ParallelizableTestModuleGroupWithSequentialInnerModules> projects = GetProjectsProperties(collection, solutionModel.SolutionProjects.Select(p => Path.Combine(rootDirectory, p.FilePath)), buildOptions);
39+
logger?.ReallyShutdown();
3640

3741
return (projects, isBuiltOrRestored);
3842
}
@@ -46,9 +50,11 @@ public static (IEnumerable<ParallelizableTestModuleGroupWithSequentialInnerModul
4650
return (Array.Empty<ParallelizableTestModuleGroupWithSequentialInnerModules>(), isBuiltOrRestored);
4751
}
4852

49-
var collection = new ProjectCollection(globalProperties: CommonRunHelpers.GetGlobalPropertiesFromArgs([.. buildOptions.MSBuildArgs]), null, toolsetDefinitionLocations: ToolsetDefinitionLocations.Default);
53+
FacadeLogger? logger = LoggerUtility.DetermineBinlogger([.. buildOptions.MSBuildArgs], dotnetTestVerb);
54+
var collection = new ProjectCollection(globalProperties: CommonRunHelpers.GetGlobalPropertiesFromArgs([.. buildOptions.MSBuildArgs]), logger is null ? null : [logger], toolsetDefinitionLocations: ToolsetDefinitionLocations.Default);
5055

5156
IEnumerable<ParallelizableTestModuleGroupWithSequentialInnerModules> projects = SolutionAndProjectUtility.GetProjectProperties(projectFilePath, collection, buildOptions.NoLaunchProfile);
57+
logger?.ReallyShutdown();
5258

5359
return (projects, isBuiltOrRestored);
5460
}

src/Cli/dotnet/Commands/Test/SolutionAndProjectUtility.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ static RunProperties GetRunProperties(ProjectInstance project, ICollection<ILogg
245245
// NOTE: BuildManager is singleton.
246246
lock (s_buildLock)
247247
{
248-
if (!project.Build(s_computeRunArgumentsTarget, loggers: loggers))
248+
if (!project.Build(s_computeRunArgumentsTarget, loggers: null))
249249
{
250250
Logger.LogTrace(() => $"The target {s_computeRunArgumentsTarget} failed to build. Falling back to TargetPath.");
251251
return new RunProperties(project.GetPropertyValue(ProjectProperties.TargetPath), null, null);

0 commit comments

Comments
 (0)