Handle runtimeconfig.dev.json without additionalProbingPaths#16166
Merged
Conversation
DotnetTestHostManager.GetTestHostPath read 'additionalProbingPaths' from
runtimeconfig.dev.json using GetProperty (NETCOREAPP) and a dictionary indexer
(NETFRAMEWORK), both of which throw when the property is absent. The .NET SDK
now emits a runtimeconfig.dev.json for net6.0+ Debug builds that may only carry
other runtime options (e.g. Hot Reload switches), causing a KeyNotFoundException
that aborted the test run. Use TryGetProperty / TryGetValue and skip the probing
path lookup when the property is missing.
Adds a filesystem integration test covering a dev config without
additionalProbingPaths on both the NETCOREAPP and NETFRAMEWORK code paths.
Contributor
There was a problem hiding this comment.
Pull request overview
Improves DotnetTestHostManager robustness when parsing *.runtimeconfig.dev.json by tolerating Debug-time SDK-emitted files that omit runtimeOptions.additionalProbingPaths, preventing test runs from aborting due to missing JSON properties.
Changes:
- Update
GetTestHostPathto useTryGetProperty/TryGetValueand skip probing-path resolution whenadditionalProbingPathsis absent. - Add a filesystem integration test validating
GetTestHostProcessStartInfosucceeds whenruntimeconfig.dev.jsonexists but does not defineadditionalProbingPaths.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs |
Makes runtimeconfig.dev.json probing-path parsing tolerant of missing additionalProbingPaths on both NETCOREAPP and NETFRAMEWORK code paths. |
test/Microsoft.TestPlatform.TestHostProvider.UnitTests/Hosting/DotnetTestHostManagerFilesystemIntegrationTests.cs |
Adds regression coverage ensuring resolution falls back to testhost.dll next to the test assembly when probing paths are not provided. |
nohwnd
approved these changes
Jun 25, 2026
This was referenced Jun 25, 2026
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.
Fix issue blocking dotnet/sdk#53715
Change by Copilot.
DotnetTestHostManager.GetTestHostPath read 'additionalProbingPaths' from
runtimeconfig.dev.json using GetProperty (NETCOREAPP) and a dictionary indexer
(NETFRAMEWORK), both of which throw when the property is absent. The .NET SDK
now emits a runtimeconfig.dev.json for net6.0+ Debug builds that may only carry
other runtime options (e.g. Hot Reload switches), causing a KeyNotFoundException
that aborted the test run. Use TryGetProperty / TryGetValue and skip the probing
path lookup when the property is missing.
Adds a filesystem integration test covering a dev config without
additionalProbingPaths on both the NETCOREAPP and NETFRAMEWORK code paths.