NuGet / Home

Repo for NuGet Client issues
Other
1.5k stars 252 forks source link

[Bug]: Improve error message when transitive package has same name as project in solution #11788

Open Smaug123 opened 2 years ago

Smaug123 commented 2 years ago

NuGet Product Used

dotnet.exe, MSBuild.exe

Product Version

6.0.2

Worked before?

No response

Impact

It bothers me. A fix would be nice

Repro Steps & Context

  1. Create an fsproj called Pulumi.fsproj with the following contents:
<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>net6.0</TargetFramework>
    </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="Pulumi" Version="3.31.0" />
    </ItemGroup>
</Project>
  1. Perform dotnet build.
  2. Observe the build failure:
➜  Pulumi git:(main) ✗ dotnet build                                                                                                                                                                                                     ~/Documents/GitHub/Pulumi/Pulumi
Microsoft (R) Build Engine version 17.1.1+a02f73656 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
/Users/patrick/Documents/GitHub/Pulumi/Pulumi/Pulumi.fsproj : error NU1108: Cycle detected.
/Users/patrick/Documents/GitHub/Pulumi/Pulumi/Pulumi.fsproj : error NU1108:   Pulumi -> Pulumi (>= 3.31.0).
  Failed to restore /Users/patrick/Documents/GitHub/Pulumi/Pulumi/Pulumi.fsproj (in 263 ms).

Build FAILED.

/Users/patrick/Documents/GitHub/Pulumi/Pulumi/Pulumi.fsproj : error NU1108: Cycle detected.
/Users/patrick/Documents/GitHub/Pulumi/Pulumi/Pulumi.fsproj : error NU1108:   Pulumi -> Pulumi (>= 3.31.0).
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.12  

Workaround is to rename your fsproj.

Verbose Logs

➜  Pulumi git:(main) ✗ dotnet --info                                                                                                                                                                                                    ~/Documents/GitHub/Pulumi/Pulumi
.NET SDK (reflecting any global.json):
 Version:   6.0.202
 Commit:    f8a55617d2

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  12.3
 OS Platform: Darwin
 RID:         osx.12-arm64
 Base Path:   /nix/store/gxi5wip6ycshmwdxhlk7an2rsk9brzk4-dotnet-sdk-6.0.202/sdk/6.0.202/

Host (useful for support):
  Version: 6.0.4
  Commit:  be98e88c76

.NET SDKs installed:
  6.0.202 [/nix/store/gxi5wip6ycshmwdxhlk7an2rsk9brzk4-dotnet-sdk-6.0.202/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.4 [/nix/store/gxi5wip6ycshmwdxhlk7an2rsk9brzk4-dotnet-sdk-6.0.202/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.4 [/nix/store/gxi5wip6ycshmwdxhlk7an2rsk9brzk4-dotnet-sdk-6.0.202/shared/Microsoft.NETCore.App]

Output of dotnet build --verbosity diag is too long for the template, so I'll attach in a comment.

Smaug123 commented 2 years ago

dotnet build --verbosity diag as promised.

Smaug123 commented 2 years ago

I found the related https://github.com/NuGet/Home/issues/1428 which was closed as "won't fix". Could we at least have an error message of the form "NuGet does not support projects with the same name as any of their dependencies"?