dotnet / dotnet/sdk

dotnet test path/to/project.csproj fails with an unhandled exception in .NET 11 RC1

Open
#56,196 5 comments 1 reaction 0 assignees View on GitHub
Area-dotnet test Area-dotnet test (MTP) Bug
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

### Describe the bug

After upgrading to .NET 11 RC1, running unit tests on the command line fails with an unhandled exception.

This exception did not occur with .NET 11 Preview 7, and it does not occur with .NET SDK 10.0.401.

### Steps to reproduce

See https://github.com/jonsagara/DotnetTestBrokenReproduction

1. Clone that repo
2. Switch to branch `feature/net11rc1`
3. Execute either of the following commands from the command line in the solution root

`dotnet test src/AwesomeLibrary.Tests/AwesomeLibrary.Tests.csproj`

`dotnet test --project src/AwesomeLibrary.Tests/AwesomeLibrary.Tests.csproj`

### Expected behavior

The unit tests run and pass without issue.

### Actual behavior

You get an unhandled exception:

> Unhandled exception: The project file could not be loaded. Could not find a part of the path 'C:\Dev\SANDBOX\AwesomeLibrary\src\AwesomeLibrary.Tests\src\AwesomeLibrary.Tests\AwesomeLibrary.Tests.csproj'. C:\Dev\SANDBOX\AwesomeLibrary\src\AwesomeLibrary.Tests\src\AwesomeLibrary.Tests\AwesomeLibrary.Tests.csproj

### Is this a regression?

Yes. It works in .NET SDK 10.0.401, and it worked previously in .NET SDK 11 Preview 7.

### Are there any workarounds?

Specifying an absolute path to the .csproj works.

### dotnet --info output

```console
.NET SDK:
Version: 11.0.100-rc.1.26425.128
Commit: 3551975be0
Workload version: 11.0.100-manifests.a6e318ce
MSBuild version: 18.11.0-1.26425.128+3551975be

Runtime Environment:
OS Name: Windows
OS Version: 10.0.26200
OS Platform: Windows
RID: win-arm64
Base Path: C:\Program Files\dotnet\sdk\11.0.100-rc.1.26425.128

.NET workloads installed:
[android]
Installation Source: VS 18.11.12202.211, VS 18.10.12201.205
Manifest Version: 37.0.0-preview.6.59/11.0.100-preview.6
Manifest Path: C:\Program Files\dotnet\sdk-manifests\11.0.100-preview.6\microsoft.net.sdk.android\37.0.0-preview.6.59\WorkloadManifest.json
Install Type: Msi

[maui-windows]
Installation Source: VS 18.11.12202.211, VS 18.10.12201.205
Manifest Version: 11.0.0-preview.6.26360.8/11.0.100-preview.6
Manifest Path: C:\Program Files\dotnet\sdk-manifests\11.0.100-preview.6\microsoft.net.sdk.maui\11.0.0-preview.6.26360.8\WorkloadManifest.json
Install Type: Msi

[maccatalyst]
Installation Source: VS 18.11.12202.211, VS 18.10.12201.205
Manifest Version: 26.5.11720-net11-p6/11.0.100-preview.6
Manifest Path: C:\Program Files\dotnet\sdk-manifests\11.0.100-preview.6\microsoft.net.sdk.maccatalyst\26.5.11720-net11-p6\WorkloadManifest.json
Install Type: Msi

[ios]
Installation Source: VS 18.11.12202.211, VS 18.10.12201.205
Manifest Version: 26.5.11720-net11-p6/11.0.100-preview.6
Manifest Path: C:\Program Files\dotnet\sdk-manifests\11.0.100-preview.6\microsoft.net.sdk.ios\26.5.11720-net11-p6\WorkloadManifest.json
Install Type: Msi

Configured to use workload sets when installing new manifests.
No workload sets are installed. Run "dotnet workload restore" to install a workload set.

Host:
Version: 11.0.0-rc.1.26425.128
Architecture: arm64
Commit: 3551975be0

.NET SDKs installed:
9.0.318 [C:\Program Files\dotnet\sdk]
10.0.100-rc.1.25451.107 [C:\Program Files\dotnet\sdk]
10.0.203 [C:\Program Files\dotnet\sdk]
10.0.401 [C:\Program Files\dotnet\sdk]
11.0.100-rc.1.26425.128 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.31 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 11.0.0-rc.1.26425.128 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.31 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 11.0.0-rc.1.26425.128 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 8.0.31 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 10.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 10.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 11.0.0-rc.1.26425.128 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x64 [C:\Program Files\dotnet\x64]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x64\InstallLocation]
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

global.json file:
C:\Dev\SANDBOX\AwesomeLibrary\global.json

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download
```

### IDE version

_No response_

### Other details

_No response_

Contributor guide

No contributing guide indexed for this repository

Research direction

Clone the linked reproduction, switch to feature/net11rc1, and run both relative-path dotnet test commands under .NET 11 RC1, then compare with SDK 10.0.401 and an absolute path. Trace the CLI project-path handling and verify that the relative commands run and pass without constructing a duplicated path.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.