Error: An item with the same key has already been added

Krzysztof Marczak's Avatar

Krzysztof Marczak

11 Jul, 2024 04:22 PM

Hi
Since June 20 my project fails to built with Appveyor.
The build script fails at the beginning when it tries to download NuGet packages. The only error message is:
An item with the same key has already been added

The yml configuration file is under this link: https://github.com/buddhi1980/mandelbulber2/blob/master/.appveyor.yml
The project can be build without any issues outside the Appveyor (on any local machine with Visual Studio 2019 or 2022)

The problem could be related to the issue reported here (problem with NuGet): https://github.com/NuGet/Home/issues/13456

It is the build log:

Build started
iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
Remote Desktop connection details:
  Server: 67.225.164.102:33952
  Username: appveyor
  Password: 7l#jlxOsvlqqqj(
git clone -q --branch=master https://github.com/buddhi1980/mandelbulber2.git C:\projects\mandelbulber2
git checkout -qf 60d98c349d0742e8d9d5fd29d373b59bcef7a8a8
nuget restore %APPVEYOR_BUILD_FOLDER%\mandelbulber2\msvc\mandelbulber2.sln
MSBuild auto-detection: using msbuild version '16.11.2.50704' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin'.
An item with the same key has already been added.
Command exited with code 1
ECHO "TRY AND TRY AGAIN"
...

Can you help me to figure out what is wrong?

  1. Support Staff 1 Posted by Owen McDonnell on 12 Jul, 2024 03:04 PM

    Owen McDonnell's Avatar

    Well that does coincide with an image update we released, which included nuget 6.10. Try a build with image: Previous Visual Studio 2019, and if it runs without that error, it's pretty certain its a nuget 6.10 issue.
    Looks like a fix for it has been merged so likely will be included in the next release.

  2. 2 Posted by Krzysztof Marcz... on 17 Jul, 2024 04:08 PM

    Krzysztof Marczak's Avatar

    Hi
    Thank you so much for your help! Your advice to use Previous Visual Studio
    2019 image made it work.
    Best Regards
       Krzysztof

    pt., 12 lip 2024 o 17:04 Owen McDonnell <[email blocked]>
    napisał(a):

  3. Support Staff 3 Posted by Owen McDonnell on 17 Jul, 2024 11:09 PM

    Owen McDonnell's Avatar

    Glad to hear its working. However keep in mind that Previous images are not meant to be a long term solution and we typically don't keep them around for that long. Therefore, before the next image update you may want to add something like the following to a ps1 script to manually update nuget until we release a new image.

    $nugetVersion = '6.10.1'
    $nugetUrl = "https://dist.nuget.org/win-x86-commandline/v$nugetVersion/nuget.exe"
    
    $nugetDir = "$env:SystemDrive\Tools\NuGet"
    
    (New-Object Net.WebClient).DownloadFile($nugetUrl, "$nugetDir\nuget.exe")
    
    (nuget).split("`n")[0]
    
    nuget sources add -name nuget.org -source https://api.nuget.org/v3/index.json
    
    Write-Host "NuGet updated" -ForegroundColor Green
    
  4. Feodor Fitsner closed this discussion on 17 Sep, 2024 09:03 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac