Report MSBuild errors from dotnet test device deploy and run-argument builds - #55524
Merged
Evangelink merged 2 commits intoJul 30, 2026
Merged
Conversation
The DeployToDevice and ComputeRunArguments builds in the MTP test path only attached the binary logger, which is null unless -bl was passed and never forwards to the console. Failures were therefore reported as 'fix the errors and warnings and run again' with no error printed anywhere. Attach a quiet console logger (unless -noConsoleLogger was passed), matching what dotnet run does in RunCommand.InvokeRunArgumentsTarget. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8786482b-05a7-4dc4-a9a3-6848cb7433c3
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the dotnet test device-deploy and run-argument discovery experience by ensuring MSBuild failures from the in-proc ProjectInstance.Build(...) calls are actually surfaced to the user (instead of failing with only a generic “fix errors and warnings” message).
Changes:
- Attach a quiet console logger (unless
-noConsoleLoggerwas passed) alongside the binlog facade logger for theDeployToDeviceandComputeRunArgumentsin-proc builds. - Extend device-selection tests to assert the underlying MSBuild error text is printed for both deploy and run-argument failures.
- Add a test-asset hook to intentionally fail
ComputeRunArgumentsfor coverage.
Show a summary per file
| File | Description |
|---|---|
| test/TestAssets/TestProjects/DotnetTestDevices/DotnetTestDevices.csproj | Adds a BeforeTargets="ComputeRunArguments" failure hook to simulate MSBuild errors in that target. |
| test/dotnet.Tests/CommandTests/Test/GivenDotnetTestSelectsDevice.cs | Updates/extends tests to assert MSBuild error output is visible for deploy and compute-run-arguments failure paths. |
| src/Cli/dotnet/Commands/Test/MTP/SolutionAndProjectUtility.cs | Introduces CreateBuildLoggers(...) and uses it for in-proc deploy + run-argument builds to ensure errors/warnings are logged. |
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 0
Evangelink
enabled auto-merge
July 29, 2026 16:51
…-msbuild-errors-in-test-device-bui # Conflicts: # src/Cli/dotnet/Commands/Test/MTP/SolutionAndProjectUtility.cs
azat-msft
approved these changes
Jul 30, 2026
Evangelink
deleted the
dev/amauryleve/report-msbuild-errors-in-test-device-bui
branch
July 30, 2026 11:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #55502 (comment).
The problem
SolutionAndProjectUtility.DeployAndGetRunPropertiesbuildsDeployToDeviceandComputeRunArgumentson aProjectInstance, passing only theFacadeLoggerreturned byLoggerUtility.DetermineBinlogger(...). That logger isnullunless the user passed/bl, so in the common case the build runs with no loggers at all:ProjectInstance.Buildcreates a freshBuildParameters()and only populatesLoggerswhen the argument is non-null — it does not fall back to theProjectCollection's loggers. And even with-bl,FacadeLoggeronly forwards toBinaryLoggers, never to the console.The result is that any MSBuild error in these targets is invisible and the user only sees:
with no errors or warnings printed anywhere. That is exactly what made #55502 (
MSB4018/ duplicateMicrosoft.NETCore.App) a binlog-only investigation.dotnet rundoes not have this problem:RunCommand.InvokeRunArgumentsTargetalways attaches a quiet console logger unless-noConsoleLoggerwas passed, andRunCommandSelector.GetLoggersdoes the same for the device-selection builds.The fix
Add
SolutionAndProjectUtility.CreateBuildLoggers, which yields the binlog facade logger (when present) plus a fresh console logger at quiet verbosity unless-noConsoleLoggerwas passed, and use it for both theDeployToDeviceandComputeRunArgumentsbuilds. Quiet verbosity keeps successful runs silent while still reporting errors and warnings. A fresh console logger is created per build, matchingRunCommandSelector's comment about disposal across multipleBuild()calls.After the change, the failure looks like:
Tests
ItFailsWhenDeployToDeviceTargetFailsnow also asserts the underlying MSBuild error text is printed.ItFailsWhenComputeRunArgumentsTargetFails, with aFailComputeRunArgumentshook added to theDotnetTestDevicestest asset, covering theComputeRunArgumentspath from the linked discussion.Verified locally against a Debug redist build:
GivenDotnetTestSelectsDeviceMicrosoft.DotNet.Cli.Test.Tests