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

avoid duplicate nuget packages #1344

Open
cwuethrich opened this issue Mar 7, 2024 · 1 comment
Open

avoid duplicate nuget packages #1344

cwuethrich opened this issue Mar 7, 2024 · 1 comment
Labels

Comments

@cwuethrich
Copy link

cwuethrich commented Mar 7, 2024

Usage Information

7.0.6 / 8.0.101 / net8.0 / Windows

Description

When you install a .NET tool as a local tool, two .nupkg files appear in the package folder. This might be a bug in dotnet, but it would be challenging to get this fixed.

The package resolver of NUKE expects to find only one package of the same version. We should change this behavior to allow multiple files of the same version and ignore the duplicates.

For example, for dotnetsay, you can find dotnetsay.2.1.7.nupkg and dotnetsay.nupkg under the folder %USERPROFILE%\.nuget\packages\dotnetsay\2.1.7.

Reproduction Steps

Make sure this folder %USERPROFILE%\.nuget\packages\swashbuckle.aspnetcore.cli\6.5.0 doesn't exist.

dotnet new tool-manifest
dotnet tool install --version 6.5.0 Swashbuckle.AspNetCore.Cli

The package was downloaded to the folder %USERPROFILE%\.nuget\packages\swashbuckle.aspnetcore.cli\6.5.0, and the two files swashbuckle.aspnetcore.cli.6.5.0.nupkg and Swashbuckle.AspNetCore.Cli.nupkg appear in this folder.

Expected Behavior

Nuke should ignore the file Swashbuckle.AspNetCore.Cli.nupkg, as it is a copy of swashbuckle.aspnetcore.cli.6.5.0.nupkg.

Actual Behavior

Nuke throws an exception "Package 'Swashbuckle.AspNetCore.Cli' is referenced with multiple versions. Use NuGetPackageResolver and SetToolPath." with inner exception "Sequence contains more than one matching element".

Regression?

I don't think this case was handled before.

Known Workarounds

I will attach a pull request, as there is no possible workaround.

Could you help with a pull-request?

Yes

@mlaily
Copy link

mlaily commented Apr 25, 2024

I believe I'm hitting the problem described here.

Actually, just calling NuGetPackageResolver.GetLocalInstalledPackages(NuGetToolPathResolver.NuGetAssetsConfigFile).ToList() is enough to trigger an exception because the .SingleOrDefault() has multiple matching items in my current .net 8 solution:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants