Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio, Nuget package sources, Order doesn't stick

for our work, we have three local nuget repos along with nuget.org and M$. I tried to reorder them like this:

Desired order

but when I saved that, then opened the settings again, my new order was gone:

New order didn't stick

What am I doing wrong?

like image 950
user1443098 Avatar asked Apr 16 '19 17:04

user1443098


2 Answers

So this is indeed a bug in the VS 2017 and VS 2019 UI, in that it sometimes (often?) can't save your chosen order. I poked around a bit, having been bitten by the same bug today myself, and the good news is that you can fix the package order yourself, outside of Visual Studio, because it's just stored in a text file on disk.

Close Visual Studio, and then go into C:\Users\[your name]\AppData\Roaming\NuGet\, and you'll find a NuGet.Config file that contains XML that looks something like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <packageSources>
        <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
        <add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" />
        <add key="My Local Packages" value="C:\Code\NugetPackages" />
        ...
     </packageSources>

     ...

 </configuration>

Notice that those <add ... /> elements exactly match what you see in the Nuget Package Manager UI, in the same order. So you can manually reorder the <add ... /> elements in this file to whatever order you want your package sources in, and save it; and both Nuget and Visual Studio will respect the new order you've chosen.

like image 72
Sean Werkema Avatar answered Oct 03 '22 05:10

Sean Werkema


I can reproduced this issue in the VS 2017 latest version and have already reported this issue to the VS Product Team, please check this: Tools-Options-NuGet Package Manager-Package Sources: the order of the available package sources not saved and you can add a comment to follow the response comes from the product team engineer, thanks.

like image 32
Sara Liu - MSFT Avatar answered Oct 03 '22 06:10

Sara Liu - MSFT