dotnet / dotnet/sdk

Additional ProjectReference if the referenced project has an ampersand in its path

Open
#49,632 0 comments 0 reactions 0 assignees View on GitHub
Area-NetSDK untriaged
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

### Describe the bug

If a referenced project has an ampersand in its path, it ends up duplicated in the ProjectReference item group.

### To Reproduce

Test project:

[transitiveProjectReference-d80d127.zip](https://github.com/user-attachments/files/21018222/transitiveProjectReference-d80d127.zip)

Run repro.sh, it will build a console project twice, once with a normal project reference, the second time with a project reference that has an ampersand in its path:

```
$ ./repro.sh
+ dotnet build /bl:working.binlog consoleapp/consoleapp.csproj /p:Mode=working
Restore complete (0.3s)
baselib succeeded (1.0s) → baselib/bin/Debug/net9.0/baselib.dll
consoleapp succeeded with 1 warning(s) (1.0s) → consoleapp/bin/Debug/net9.0/consoleapp.dll
/Users/rolf/test/dotnet/transitiveProjectReference/consoleapp/consoleapp.csproj(17,5): warning : ../baselib/baselib.csproj

Build succeeded with 1 warning(s) in 2.6s
+ dotnet build /bl:failing.binlog consoleapp/consoleapp.csproj /p:Mode=failing
Restore complete (0.3s)
baselib & more succeeded (0.9s) → baselib2/bin/Debug/net9.0/baselib & more.dll
consoleapp failed with 1 error(s) and 1 warning(s) (0.9s) → consoleapp/bin/Debug/net9.0/consoleapp.dll
/Users/rolf/test/dotnet/transitiveProjectReference/consoleapp/consoleapp.csproj(17,5): warning : ../baselib2/baselib & more.csproj;../baselib2/baselib & more.csproj
/Users/rolf/test/dotnet/transitiveProjectReference/consoleapp/consoleapp.csproj(18,5): error : More than one project reference!

Build failed with 1 error(s) and 1 warning(s) in 2.3s
```

The problem seems to be in the ResolvePackageAssets test, in the failing case, it seems to think the console project doesn't have an actual ProjectReference to the referenced project, so it re-adds it (thus duplicating it) as if it were a transitive reference:

![Image](https://github.com/user-attachments/assets/27d33674-2ceb-4138-96c0-9b96791f2502)

This does not happen in the working case:

![Image](https://github.com/user-attachments/assets/af9876eb-3e87-4167-885e-bb537622f89c)

### Further technical details

```
$ dotnet --info
.NET SDK:
Version: 9.0.300
Commit: 15606fe0a8
Workload version: 9.0.301.1
MSBuild version: 17.14.5+edd3bbf37

Runtime Environment:
OS Name: Mac OS X
OS Version: 15.5
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/9.0.300/

.NET workloads installed:
[macos]
Installation Source: SDK 9.0.300
Manifest Version: 15.5.9199/9.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/9.0.100/microsoft.net.sdk.macos/15.5.9199/WorkloadManifest.json
Install Type: FileBased

[ios]
Installation Source: SDK 9.0.300
Manifest Version: 18.5.9199/9.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/9.0.100/microsoft.net.sdk.ios/18.5.9199/WorkloadManifest.json
Install Type: FileBased

[maccatalyst]
Installation Source: SDK 9.0.300
Manifest Version: 18.5.9199/9.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/9.0.100/microsoft.net.sdk.maccatalyst/18.5.9199/WorkloadManifest.json
Install Type: FileBased

Configured to use workload sets when installing new manifests.

Host:
Version: 9.0.5
Architecture: arm64
Commit: e36e4d1a8f

.NET SDKs installed:
6.0.425 [/usr/local/share/dotnet/sdk]
7.0.410 [/usr/local/share/dotnet/sdk]
8.0.304 [/usr/local/share/dotnet/sdk]
8.0.402 [/usr/local/share/dotnet/sdk]
9.0.100 [/usr/local/share/dotnet/sdk]
9.0.102 [/usr/local/share/dotnet/sdk]
9.0.103 [/usr/local/share/dotnet/sdk]
9.0.106 [/usr/local/share/dotnet/sdk]
9.0.203 [/usr/local/share/dotnet/sdk]
9.0.300 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.33 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.20 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.0-rc.2.24474.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.33 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.36 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.20 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
None

Environment variables:
Not set

global.json file:
Not found

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

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

This is on macOS, command line.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.