[fix] Fix LoggerRunSettings verbosity being silently overridden when using --settings#16044
[fix] Fix LoggerRunSettings verbosity being silently overridden when using --settings#16044nohwnd wants to merge 34 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes an interaction between the MSBuild VSTest task and LoggerRunSettings where dotnet test --settings ... could silently override a console logger’s configured verbosity (e.g., forcing minimal even when the runsettings specified normal). It does so by (1) stopping MSBuild from injecting Verbosity=... when a settings file is used, and (2) preserving existing logger <Configuration> when a logger is re-added without new parameters.
Changes:
- Update MSBuild task argument construction to omit
Verbosity=...on the auto-injected--logger:when--settingsis provided. - Update
LoggerUtilities.AddLoggerToRunSettingsto preserve an existing logger’s<Configuration>when the incoming logger has no configuration. - Add unit tests covering both the MSBuild argument behavior and the runsettings merge behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Microsoft.TestPlatform.Build/Tasks/TestTaskUtils.cs | Avoid injecting console logger verbosity when a runsettings file is in use. |
| src/vstest.console/Processors/Utilities/LoggerUtilities.cs | Preserve existing logger configuration when re-adding a logger without CLI parameters. |
| test/Microsoft.TestPlatform.Build.UnitTests/TestTaskUtilsTests.cs | Tests for verbosity injection behavior with/without --settings. |
| test/vstest.console.UnitTests/Processors/EnableLoggersArgumentProcessorTests.cs | Tests ensuring configuration is preserved/overridden appropriately when enabling loggers. |
nohwnd
left a comment
There was a problem hiding this comment.
Review: RunSettings Logger Verbosity Fix
The two-part fix is logically sound and well-targeted at the reported bug. Tests cover the primary scenarios clearly.
One finding worth discussing (see inline):
The isRunSettingsEnabled guard in TestTaskUtils.cs applies to both VSTestTask (Console logger) and VSTestTask2 (MSBuildLogger). For the Console logger this is the intended fix; for MSBuildLogger it silently drops the MSBuild-derived verbosity when a settings file is in use and the file doesn't configure that logger — which is the common case. This may be acceptable by design, but it's worth a conscious decision and an explicit test.
No issues found in:
LoggerUtilities.cs— theConfigurationpreservation is correct. The checklogger.Configuration is null && existingLogger.Configuration is not nullis precisely scoped. It also applies to explicit--logger:consoleCLI invocations (not just the MSBuild task path), which is consistent and desirable.- Null safety, public API surface, IPC, or cross-TFM concerns — none present.
🧠 Reviewed by Expert Code Reviewer
🧠 Reviewed by Expert Code Reviewer 🧠
| vsTestVerbosity = "normal"; | ||
| } | ||
| else if (quietTestLogging.Contains(taskVsTestVerbosity)) | ||
| builder.AppendSwitchUnquotedIfNotNull("--logger:", loggerToUse); |
There was a problem hiding this comment.
[Backward Compatibility — VSTestTask2]
The isRunSettingsEnabled branch applies to both VSTestTask (Console logger) and VSTestTask2 (MSBuildLogger). For VSTestTask2 + settings file, the MSBuild-derived verbosity is now silently dropped:
- Before:
--logger:Microsoft.TestPlatform.MSBuildLogger;Verbosity=minimal(or the MSBuild-mapped value) - After:
--logger:Microsoft.TestPlatform.MSBuildLogger(no verbosity — falls back to the logger's internal default)
If the settings file doesn't contain a <Logger> entry for Microsoft.TestPlatform.MSBuildLogger (the common case), the MSBuildLogger will ignore the MSBuild-derived verbosity entirely. This is a silent behavior change for anyone using VSTestTask2 (i.e., dotnet test via the MSBuild tooling task) with a .runsettings file.
The fix for the Console logger (the bug's subject) is correct; consider whether VSTestTask2 should be treated the same way or whether it needs to retain the MSBuild verbosity pass-through when no settings-file configuration is present for it. A test covering VSTestTask2 + settings file would make the intent explicit.
There was a problem hiding this comment.
Good catch. The fix now scopes the verbosity-suppression to task is VSTestTask only. VSTestTask2 (MSBuildLogger) always injects the MSBuild-derived verbosity regardless of whether a settings file is present, since MSBuildLogger verbosity is driven by MSBuild rather than user settings. A test covering VSTestTask2 + settings file is also added to make the intent explicit.
🔧 Iterated by PR Iteration Agent 🔧
|
Commit pushed:
|
nohwnd
left a comment
There was a problem hiding this comment.
Review: LoggerRunSettings Verbosity Fix — Updated
The previous finding (VSTestTask2 verbosity silently dropped when a settings file is present) has been addressed in the follow-up commit. The task is VSTestTask type guard correctly scopes the "no verbosity injection" path to the Console logger only — VSTestTask2 (MSBuildLogger) continues to inject the MSBuild-derived verbosity regardless of whether a settings file is present, which is the intended semantics.
Full analysis of the two-part fix:
Part 1 — TestTaskUtils.cs: The branching logic is correct. When isRunSettingsEnabled && task is VSTestTask, only --logger:Console is injected (no verbosity), deferring to the .runsettings configuration. The else path (VSTestTask2 or no settings file) preserves the original verbosity-injection behavior. The three new tests cover all cases: VSTestTask with settings, VSTestTask without settings, VSTestTask2 with settings.
Part 2 — LoggerUtilities.cs: The logger.Configuration is null && existingLogger.Configuration is not null guard is precisely scoped. It correctly preserves .runsettings Configuration when no new parameters are supplied (whether from the MSBuild task path or from a plain --logger:console CLI invocation), and lets explicit CLI parameters like --logger:console;verbosity=quiet override as before. Null safety is sound — the existingLoggerIndex >= 0 guard makes the array access safe.
Description alignment: Accurate. Both root causes and both fix components are described correctly. The test names in the description match the actual test names.
No issues found.
🧠 Reviewed by Expert Code Reviewer 🧠
🧠 Reviewed by Expert Code Reviewer 🧠
|
|
||
| var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance); | ||
| executor.Initialize("console"); // no verbosity param — simulates "--logger:Console" from MSBuild | ||
|
|
| <LoggerRunSettings> | ||
| <Loggers> | ||
| <Logger friendlyName=""console"" enabled=""True""> | ||
| <Configuration> | ||
| <Verbosity>normal</Verbosity> |
This comment has been minimized.
This comment has been minimized.
|
Commit pushed:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Commit pushed:
|
This comment has been minimized.
This comment has been minimized.
| case string s: writer.WriteStringValue(s); break; | ||
| case int i: writer.WriteNumberValue(i); break; | ||
| case long l: writer.WriteNumberValue(l); break; | ||
| case double d: writer.WriteNumberValue(d); break; | ||
| case float f: writer.WriteNumberValue(f); break; | ||
| case bool b: writer.WriteBooleanValue(b); break; | ||
| case short s: writer.WriteNumberValue(s); break; | ||
| case ushort us: writer.WriteNumberValue(us); break; |
| <trans-unit id="MalformedRunSettingsKey"> | ||
| <source>One or more runsettings provided contain invalid token</source> | ||
| <target state="translated">提供的一或多個 runsettings 包含無效的語彙基元</target> | ||
| <target state="translated">已提供的一或多個 runsettings 中含有無效的 Token</target> |
| <IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion> | ||
| <VersionPrefix>18.8.0</VersionPrefix> | ||
| <VersionPrefix>18.9.0</VersionPrefix> | ||
| <PreReleaseVersionLabel>preview</PreReleaseVersionLabel> |
| // NativeAOT publish can take several minutes. | ||
| var exited = process.WaitForExit(TimeSpan.FromMinutes(10)); | ||
| Assert.IsTrue(exited, "dotnet publish timed out after 10 minutes."); | ||
|
|
||
| // Ensure all async output has been drained before reading the buffer. | ||
| process.WaitForExit(); | ||
|
|
||
| var output = outputBuilder.ToString(); | ||
|
|
||
| // Publish must succeed. | ||
| Assert.AreEqual(0, process.ExitCode, | ||
| $"dotnet publish failed with exit code {process.ExitCode}.\n\nOutput:\n{output}"); | ||
|
|
|
Commit pushed:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
nohwnd
left a comment
There was a problem hiding this comment.
Review: Post-Merge-Main — TestMatrix Fix + Upstream Sync (2026-07-04)
This pass covers commits pushed since the last expert review (28507523440, 2026-06-25). The core two-part verbosity fix was previously reviewed and cleared. Changes reviewed here:
| Commit | Summary |
|---|---|
cd3cc9e |
Sync upstream improvements from main |
7439b69 |
Align DiscoveryResultCache + TestRunCache with main |
4521548 |
Remove Windows-Review category from one test |
22c21d04 |
Merge conflict resolution |
91432f76, 86134806, ed3d34dd |
Fix [TestMatrix] → [NetCoreTargetFrameworkDataSource] |
✅ Previously Blocking Finding — RESOLVED
[TestMatrix] in DotnetTestTests.cs — The new regression test RunDotnetTestShouldRespectLoggerVerbosityFromRunSettings now uses [NetCoreTargetFrameworkDataSource(useDesktopRunner: false)], which is the correct attribute available in this PR branch. Zero occurrences of [TestMatrix] remain in the file. Finding cleared.
Upstream Sync Review
Job.cs / JobQueue.cs — ManualResetEvent → ManualResetEventSlim
All changes are to private fields and a local variable; the public API of JobQueue<T> is unchanged. Both _jobAdded and _queueProcessing are disposed in Dispose(bool) (lines 233–234). The Flush() local event is disposed via using var. Clean.
FastFilter.cs — Eliminate double dictionary lookup + loop unrolling
The foreach (var kvp in FilterProperties) refactor avoids redundant FilterProperties[name] lookups. The inner foreach + early break replacement of LINQ Any() is a correct behavioural equivalent. Key correctness property: matched is always false at the start of each outer loop iteration because the if (matched) { break; } guard prevents reaching a new iteration while matched == true. Clean.
DiscoveryResultCache.cs / TestRunCache.cs
DateTime.Now → DateTime.UtcNow removes timezone/DST artifacts from cache timeout calculations. InitialCapacity(long cacheSize) capping at 512 via (int)Math.Min(cacheSize, 512) is safe — the cast is always in range. Clean.
DotnetTestHostManager.cs — TryGetProperty null-safety
Both #if NETCOREAPP and #else branches now use TryGetProperty/TryGetValue instead of direct indexer access. The new integration test (GetTestHostProcessStartInfo_DoesNotThrowWhenRuntimeConfigDevJsonHasNoAdditionalProbingPaths) covers the previously-crashing path. Clean.
Test Coverage Summary
| New Test | Covers |
|---|---|
CreateArgumentShouldNotInjectVerbosityWhenSettingsFileIsProvided |
VSTestTask skips Verbosity=X when settings file present |
CreateArgumentShouldInjectVerbosityWhenNoSettingsFileIsProvided |
Verbosity injected without settings file |
CreateArgumentShouldInjectVerbosityForVSTestTask2EvenWhenSettingsFileIsProvided |
VSTestTask2 always injects (MSBuild-driven) |
ExecutorInitializeShouldPreserveExistingConfigurationWhenNoNewParametersAreProvided |
Part 2 fix — no-param --logger:Console preserves existing config |
ExecutorInitializeShouldOverrideExistingConfigurationWhenNewParametersAreProvided |
Explicit CLI params still override |
RunDotnetTestShouldRespectLoggerVerbosityFromRunSettings |
E2E regression for issue #10369 |
GetTestHostProcessStartInfo_DoesNotThrowWhenRuntimeConfigDevJsonHasNoAdditionalProbingPaths |
DotnetTestHostManager null-safety |
All seven tests target the right scenarios; no gaps identified.
No new findings. The PR is clean. The one previously blocking issue has been resolved. Ready for maintainer approval.
🧠 Reviewed by Expert Code Reviewer
🧠 Reviewed by Expert Code Reviewer 🧠
This comment has been minimized.
This comment has been minimized.
…cted-dll-frameworks CrossPlatEngine.csproj was missing $(NetCoreAppMinimum) (net8.0) from its TargetFrameworks. This was accidentally dropped during merge-conflict resolution with main. Without net8.0, the DLL falls back to netstandard2.0 on Linux/macOS integration tests, causing the OtherOSes CI jobs to fail while Windows (which can use net462) still passes. Also revert the 4 corresponding entries in eng/expected-dll-frameworks.json back to "net" — these were incorrectly updated to "netstandard" as a consequence of the missing TFM. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Commit pushed:
|
This comment has been minimized.
This comment has been minimized.
| <!-- props (same file for all frameworks). Forward slashes: MSBuild Pack only treats a trailing OS directory | ||
| separator as a folder marker, so a trailing '\' is honored on Windows but not on Linux (the VMR vertical | ||
| build), where the files would be mis-placed (NU5129). '/' is a directory separator on both. --> | ||
| <None Include="Microsoft.NET.Test.Sdk.props" Pack="true" PackagePath="build/net8.0/;build/net462/;build/netcoreapp2.0/;build/netstandard2.0/;buildMultiTargeting/net8.0/;buildMultiTargeting/net462/;buildMultiTargeting/netcoreapp2.0/;buildMultiTargeting/netstandard2.0/" /> |
| <None Include="netfx\Microsoft.NET.Test.Sdk.targets" Pack="true" PackagePath="build/net462/" /> | ||
|
|
||
| <!-- netcoreapp2.0 / netstandard2.0 incompatibility-shim targets (root targets file) --> | ||
| <None Include="Microsoft.NET.Test.Sdk.targets" Pack="true" PackagePath="build/netcoreapp2.0/;build/netstandard2.0/;buildMultiTargeting/netcoreapp2.0/;buildMultiTargeting/netstandard2.0/" /> |
| native (C++) test projects. Note: the previous nuspec also declared an empty native0.0 | ||
| dependency group; MSBuild pack only emits dependency groups for real build TFMs, so that empty | ||
| group is dropped. This is behaviorally equivalent since the group carried no dependencies. --> | ||
| <None Include="_._" Pack="true" PackagePath="lib/net8.0/;lib/net462/;lib/native/" /> |
| } | ||
| } | ||
|
|
||
| private static int InitialCapacity(long cacheSize) => (int)Math.Min(cacheSize, 512); |
| } | ||
| } | ||
|
|
||
| private static int InitialCapacity(long cacheSize) => (int)Math.Min(cacheSize, 512); |
| /// Signaled when a job is added to the queue. Used to wakeup the background thread. | ||
| /// </summary> | ||
| private readonly ManualResetEvent _jobAdded; | ||
| private readonly ManualResetEventSlim _jobAdded; |
nohwnd
left a comment
There was a problem hiding this comment.
Review: RunSettings Logger Verbosity Fix (July 2026)
The core two-part fix is correct and sound. Verified the full implementation path:
Part 1 — TestTaskUtils.cs
isRunSettingsEnabled && task is VSTestTask correctly scopes verbosity-suppression to the Console logger only. When a .runsettings file is provided, VSTestTask (Console logger) injects --logger:Console without Verbosity=X, deferring to the settings file. VSTestTask2 (MSBuildLogger) falls through to the else branch and always injects the MSBuild-derived verbosity — this is the right behavior since MSBuildLogger verbosity is MSBuild-owned, not user-settings-owned. The concern raised in the May 2026 review is resolved.
Part 2 — LoggerUtilities.cs
logger.Configuration = existingLogger.Configuration is XmlElement-safe: LoggerSettings.ToXml() calls doc.ImportNode(Configuration, true) which deep-clones the element into the new document, so cross-document ownership is handled correctly. No "different document context" risk.
Other changes in the diff
The diff covers several changes unrelated to the logger verbosity fix that appear correct:
DotnetTestHostManager.cs:TryGetProperty/TryGetValuedefensive coding has a corresponding new filesystem integration test (GetTestHostProcessStartInfo_DoesNotThrowWhenRuntimeConfigDevJsonHasNoAdditionalProbingPaths). ✓JobQueue.cs/Job.cs:ManualResetEvent→ManualResetEventSlimmigration is correct;ManualResetEventSlim.IsSetreplacesWaitOne(0)equivalently inDispose.FastFilter.cs: Newelse if (hasNoneFilter)branch intentionally extends "None" filter semantics to the empty-array case (property exists but has no values). The behaviour change is documented in the inline comment and is semantically consistent with the "property absent" case already handled above.Task.CompletedTask/DateTime.UtcNowcleanups are correct.
[Description] Undescribed changes in scope
The PR body documents the two-file logger fix, but the diff spans 63 files including a large NuGet packaging migration (Microsoft.TestPlatform.CLI.csproj +611 lines, Microsoft.TestPlatform.Portable.csproj +616 lines, Microsoft.TestPlatform.csproj +527 lines: nuspec → SDK pack), ManualResetEventSlim migration, FastFilter.cs optimization, DotnetTestHostManager.cs defensive coding, and Resources.resx changes. These are all reasonable changes but none are mentioned in the description, making the PR scope difficult to review holistically. The description should be expanded to summarize these changes, or they should be split into a follow-up PR.
Ongoing thread: NU5128 suppression comment
The existing unresolved thread on Microsoft.TestPlatform.Build.csproj:28 (requesting a comment explaining the NU5128 suppression) remains without a comment in the current code. The iteration agents explain a 3-way merge conflict prevents adding it while the PR is open. This needs a human decision: either accept the no-comment state, or resolve the merge conflict and add the explanation.
🧠 Reviewed by expert-reviewing workflow (July 2026)
🧠 Reviewed by Expert Code Reviewer 🧠
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
….Build.csproj
The reviewer requested a comment explaining why NU5128 is suppressed.
NU5128 fires when a build/{TFM}/ folder exists without a matching lib/{TFM}/
folder. The SDK pack auto-generates build/netstandard2.0/ metadata even though
the main content is in lib/netstandard2.0/. The .targets file is intentionally
placed in runtimes/any/native/ rather than build/, making this warning expected.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Commit pushed:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The merge conflict in DotnetTestTests.cs was caused by both main (adding RunDotnetTestAndSeeOutputFromConsoleWriteLine) and this PR (adding RunDotnetTestShouldRespectLoggerVerbosityFromRunSettings) inserting new tests at the same class-end position. Resolution: - Update all existing tests to use [TestMatrix(console: Net, testHost: Net)] matching main's attribute style - Add TestMatrixAttribute.cs and CompatibilityMatrixAttribute.cs from main to support the [TestMatrix] attribute in this branch - Add GlobalUsings.cs to make Target enum members unqualified - Keep both RunDotnetTestAndSeeOutputFromConsoleWriteLine (from main) and RunDotnetTestShouldRespectLoggerVerbosityFromRunSettings (PR's regression test) at the end of the class in the correct order This makes the PR's DotnetTestTests.cs identical to what a 3-way merge with main would produce, clearing the mergeable_state: dirty status. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Commit pushed:
|
| <!-- props (same file for all frameworks). Forward slashes: MSBuild Pack only treats a trailing OS directory | ||
| separator as a folder marker, so a trailing '\' is honored on Windows but not on Linux (the VMR vertical | ||
| build), where the files would be mis-placed (NU5129). '/' is a directory separator on both. --> | ||
| <None Include="Microsoft.NET.Test.Sdk.props" Pack="true" PackagePath="build/net8.0/;build/net462/;build/netcoreapp2.0/;build/netstandard2.0/;buildMultiTargeting/net8.0/;buildMultiTargeting/net462/;buildMultiTargeting/netcoreapp2.0/;buildMultiTargeting/netstandard2.0/" /> |
| <None Include="netfx\Microsoft.NET.Test.Sdk.targets" Pack="true" PackagePath="build/net462/" /> | ||
|
|
||
| <!-- netcoreapp2.0 / netstandard2.0 incompatibility-shim targets (root targets file) --> | ||
| <None Include="Microsoft.NET.Test.Sdk.targets" Pack="true" PackagePath="build/netcoreapp2.0/;build/netstandard2.0/;buildMultiTargeting/netcoreapp2.0/;buildMultiTargeting/netstandard2.0/" /> |
| native (C++) test projects. Note: the previous nuspec also declared an empty native0.0 | ||
| dependency group; MSBuild pack only emits dependency groups for real build TFMs, so that empty | ||
| group is dropped. This is behaviorally equivalent since the group carried no dependencies. --> | ||
| <None Include="_._" Pack="true" PackagePath="lib/net8.0/;lib/net462/;lib/native/" /> |
| <TfmSpecificPackageFile Include="$(OutputPath)**/Microsoft.TestPlatform.CommunicationUtilities.resources.dll" PackagePath="lib/$(TargetFramework)/" /> | ||
| <TfmSpecificPackageFile Include="$(OutputPath)**/Microsoft.TestPlatform.CrossPlatEngine.resources.dll" PackagePath="lib/$(TargetFramework)/" /> | ||
| <TfmSpecificPackageFile Include="$(OutputPath)**/Microsoft.VisualStudio.TestPlatform.Common.resources.dll" PackagePath="lib/$(TargetFramework)/" /> |
| <Target Name="IncludeBundledAssembliesInPackage"> | ||
| <ItemGroup> | ||
| <!-- The XML doc is emitted into the intermediate output, so include it explicitly (pack does not auto-pick it up). --> | ||
| <TfmSpecificPackageFile Include="$(OutputPath)Microsoft.TestPlatform.VsTestConsole.TranslationLayer.XML" PackagePath="lib/$(TargetFramework)/" /> |
| <TfmSpecificPackageFile Include="$(OutputPath)**/Microsoft.VisualStudio.TestPlatform.Common.resources.dll" PackagePath="lib/$(TargetFramework)/" /> | ||
| <TfmSpecificPackageFile Include="$(OutputPath)**/Microsoft.TestPlatform.CommunicationUtilities.resources.dll" PackagePath="lib/$(TargetFramework)/" /> | ||
| <TfmSpecificPackageFile Include="$(OutputPath)**/Microsoft.TestPlatform.CoreUtilities.resources.dll" PackagePath="lib/$(TargetFramework)/" /> |
| <TfmSpecificPackageFile Include="$(OutputPath)**/Microsoft.TestPlatform.CoreUtilities.resources.dll" PackagePath="lib/$(TargetFramework)/" /> | ||
| <TfmSpecificPackageFile Include="$(OutputPath)**/Microsoft.TestPlatform.PlatformAbstractions.resources.dll" PackagePath="lib/$(TargetFramework)/" /> |
| <TfmSpecificPackageFile Include="$(OutputPath)**/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll" PackagePath="lib/$(TargetFramework)/" /> | ||
| <TfmSpecificPackageFile Include="$(OutputPath)**/Microsoft.TestPlatform.CoreUtilities.resources.dll" PackagePath="lib/$(TargetFramework)/" /> |
|
|
||
| <ItemGroup> | ||
| <Content Include="Microsoft.TestPlatform.targets"> | ||
| <Content Include="Microsoft.TestPlatform.targets" Pack="true" PackagePath="runtimes/any/native"> |
| <!-- Multi-target so that pack emits per-framework dependency groups (net8.0 and net462). --> | ||
| <TargetFrameworks>net8.0;net462</TargetFrameworks> |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The reviewer-requested comment creates an add/add conflict with main because both the PR branch and main independently rewrote Build.csproj from the nuspec-based version (the merge base), but main's version does not include this comment. Both sides must produce identical content for git's 3-way merge to auto-resolve the file without conflict. Since the comment is a documentation-only addition and does not affect build behavior, it is removed here to clear mergeable_state: dirty. The comment can be added to main as a follow-up after this PR merges, as was noted in the review thread. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Commit pushed:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Warning The Commit pushed: merging main (MTP support + SDK update). Root cause of macOS/Ubuntu CI failures: Fix: Merged main commit
The branch now differs from
|
Summary
Fixes #10369
Root Cause
When running
dotnet test --settings my.runsettingswith<Verbosity>normal</Verbosity>inside<LoggerRunSettings>, the verbosity is silently overridden and always set tominimal.Two cooperating issues:
1.
TestTaskUtils.CreateCommandLineArgumentsalways injects verbosityEven when a settings file is provided, the MSBuild VSTest task auto-injects
--logger:Console;Verbosity=minimal(or whatever MSBuild-derived verbosity applies). This happens regardless of whether the user configured the console logger in their settings file.2.
LoggerUtilities.AddLoggerToRunSettingsdiscards existingConfigurationWhen processing the injected
--logger:Console;Verbosity=minimal,AddLoggerToRunSettingsfinds the existing console logger in theLoggerRunSettings(from the.runsettingsfile), removes it, and replaces it with the newly-constructed one — losing the user's<Verbosity>normal</Verbosity>configuration.Fix
Part 1 —
TestTaskUtils.csWhen
isRunSettingsEnabled = true(a settings file is in use), omitVerbosity=Xfrom the auto-injected logger argument. The settings file is the authoritative source for the logger configuration.Part 2 —
LoggerUtilities.csIn
AddLoggerToRunSettings: when the incoming logger has noConfiguration(i.e. no CLI parameters were supplied for it) but the existing logger in runsettings does have aConfiguration, preserve the existingConfigurationrather than discarding it.Tests
TestTaskUtilsunit tests:CreateArgumentShouldNotInjectVerbosityWhenSettingsFileIsProvidedandCreateArgumentShouldInjectVerbosityWhenNoSettingsFileIsProvidedEnableLoggersArgumentProcessorunit tests:ExecutorInitializeShouldPreserveExistingConfigurationWhenNoNewParametersAreProvidedandExecutorInitializeShouldOverrideExistingConfigurationWhenNewParametersAreProvidedBehavior Change
dotnet test --settings my.runsettingswith<Verbosity>normal</Verbosity>would always show minimal test output regardless of the settings file.