Skip to content

Commit

Permalink
Enable or disable new logger based on TL flag (#5167)
Browse files Browse the repository at this point in the history
* Enable or disable new logger based on TL flag

* Output
  • Loading branch information
nohwnd authored Aug 12, 2024
1 parent bc9d7a7 commit 5da7208
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ Copyright (c) .NET Foundation. All rights reserved.
-->
<Target Name="VSTest" DependsOnTargets="ShowInfoMessageIfProjectHasNoIsTestProjectProperty">
<!-- Unloggable colorized output (cf. https://github.com/microsoft/vstest/issues/680) -->
<CallTarget Targets="_VSTestConsole" Condition="!$(VsTestUseMSBuildOutput) OR $(MSBUILDENSURESTDOUTFORTASKPROCESSES) == '1'" />
<!-- Fallback to this old view when terminal logger is not enabled (_MSBUILDTLENABLED==0) , or when user explicitly opts out (VsTestUseMSBuildOutput != true) -->
<CallTarget Targets="_VSTestConsole" Condition="$(_MSBUILDTLENABLED) == '0' OR !$(VsTestUseMSBuildOutput) OR $(MSBUILDENSURESTDOUTFORTASKPROCESSES) == '1'" />
<!-- Proper MSBuild integration, but no custom colorization -->
<CallTarget Targets="_VSTestMSBuild" Condition="$(VsTestUseMSBuildOutput)" />
<!-- Use the new view whe terminal logger is enabled (_MSBUILDTLENABLED==0), and user did not opt out (VsTestUseMSBuildOutput == true) -->
<CallTarget Targets="_VSTestMSBuild" Condition="$(_MSBUILDTLENABLED) == '1' AND $(VsTestUseMSBuildOutput)" />
</Target>

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ public void MSBuildLoggerCanBeEnabledByBuildPropertyAndDoesNotEatSpecialChars(Ru
SetTestEnvironment(_testEnvironment, runnerInfo);

var projectPath = GetIsolatedTestAsset("TerminalLoggerTestProject.csproj");
InvokeDotnetTest($@"{projectPath} -nodereuse:false /p:VsTestUseMSBuildOutput=true /p:PackageVersion={IntegrationTestEnvironment.LatestLocallyBuiltNugetVersion}");
InvokeDotnetTest($@"{projectPath} -nodereuse:false /p:PackageVersion={IntegrationTestEnvironment.LatestLocallyBuiltNugetVersion}", new Dictionary<string, string?>
{
// Setting this temporarily, until we upgrade to final net9, which has this option set automatically in the MSBUILD sdk.
// Without this option we don't produce any output to the terminal logger.
["_MSBUILDTLENABLED"] = "1"
});

// The output:
// Determining projects to restore...
Expand Down

0 comments on commit 5da7208

Please sign in to comment.