Skip to content

Handle runtimeconfig.dev.json without additionalProbingPaths#16166

Merged
nohwnd merged 1 commit into
microsoft:mainfrom
tmat:fix-probingpaths
Jun 25, 2026
Merged

Handle runtimeconfig.dev.json without additionalProbingPaths#16166
nohwnd merged 1 commit into
microsoft:mainfrom
tmat:fix-probingpaths

Conversation

@tmat

@tmat tmat commented Jun 24, 2026

Copy link
Copy Markdown
Member

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.

    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.
Copilot AI review requested due to automatic review settings June 24, 2026 21:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 GetTestHostPath to use TryGetProperty / TryGetValue and skip probing-path resolution when additionalProbingPaths is absent.
  • Add a filesystem integration test validating GetTestHostProcessStartInfo succeeds when runtimeconfig.dev.json exists but does not define additionalProbingPaths.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants