Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unresolved packages/projects should show errors in dependency tree #8947

Closed
drewnoakes opened this issue Mar 31, 2023 · 3 comments · Fixed by NuGet/NuGet.Client#5146
Closed
Assignees
Labels
Feature-Dependency-Node "Dependencies" node in Solution Explorer that display project, binary & package references Triage-Approved Reviewed and prioritized
Milestone

Comments

@drewnoakes
Copy link
Member

drewnoakes commented Mar 31, 2023

The following project references a NuGet package that doesn't exist:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="NonExistantPackage" Version="1.2.3" />
  </ItemGroup>

</Project>

project.assets.json has the following entry:

  "logs": [
    {
      "code": "NU1101",
      "level": "Error",
      "message": "Unable to find package NonExistantPackage. No packages exist with this id in source(s): C:\\Program Files\\dotnet\\library-packs, Microsoft Visual Studio Offline Packages, NuGet local, nuget.org",
      "libraryId": "NonExistantPackage",
      "targetGraphs": [
        "net7.0"
      ]
    }
  ]

This message should be displayed in the tree, yet isn't.

image

The package node should have a child node containing the error message. Otherwise it is difficult for the user to know why the restore failed, or what the yellow triangle means.

@drewnoakes drewnoakes added Bug Feature-Dependency-Node "Dependencies" node in Solution Explorer that display project, binary & package references labels Mar 31, 2023
@drewnoakes drewnoakes self-assigned this Mar 31, 2023
@drewnoakes drewnoakes added this to the 17.7 milestone Mar 31, 2023
@drewnoakes
Copy link
Member Author

drewnoakes commented Mar 31, 2023

The Package pane of the Output window shows:

Failed to restore C:\repo\MyProject\MyProject.csproj (in 1.1 sec).
NuGet package restore failed. Please see Error List window for detailed warnings and errors.
Time Elapsed: 00:00:01.1176420
========== Finished ==========

The Error List shows:

image

@kvenkatrajan kvenkatrajan added the Triage-Approved Reviewed and prioritized label Apr 6, 2023
@drewnoakes
Copy link
Member Author

This problem also occurs for unresolved project references.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="NonExistantPackage" Version="1.2.3" />
    <ProjectReference Include="..\NonExistantProject\NonExistantProject.csproj" />
  </ItemGroup>

</Project>

In project.assets.json:

"logs": [
  {
    "code": "NU1101",
    "level": "Error",
    "message": "Unable to find package NonExistantPackage. No packages exist with this id in source(s): C:\\Program Files\\dotnet\\library-packs, Microsoft Visual Studio Offline Packages, NuGet local, nuget.org",
    "libraryId": "NonExistantPackage",
    "targetGraphs": [
      "net7.0"
    ]
  },
  {
    "code": "NU1104",
    "level": "Error",
    "message": "Unable to find project 'D:\\repos\\issues\\Issue8947UnresolvedPackageWarningMissing\\NonExistantProject\\NonExistantProject.csproj'. Check that the project reference is valid and that the project file exists.",
    "libraryId": "D:\\repos\\issues\\Issue8947UnresolvedPackageWarningMissing\\NonExistantProject\\NonExistantProject.csproj",
    "targetGraphs": [
      "net7.0"
    ]
  }
]

In the UI:

image

@drewnoakes drewnoakes changed the title Package restore errors not visible in dependency tree Package/project restore errors not visible in dependency tree Apr 24, 2023
@drewnoakes
Copy link
Member Author

Turns out the fix for this was in our code in the NuGet.Client repo. Fixed in NuGet/NuGet.Client#5146.

@drewnoakes drewnoakes changed the title Package/project restore errors not visible in dependency tree Unresolved packages/projects should show errors in dependency tree Apr 24, 2023
@drewnoakes drewnoakes removed the Bug label Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature-Dependency-Node "Dependencies" node in Solution Explorer that display project, binary & package references Triage-Approved Reviewed and prioritized
Projects
None yet
2 participants