Can't get rid of NuGet official package source

2019-08-28 01:52发布

I go into the Package Manager -> Package Sources options and remove the NuGet official package source so that only my local source is available. Then I close visual studio 2010. As soon as I re-open Visual Studio, the NuGet official package source is still at the top of Available Package Sources. https://go.microsoft.com/fwlink/?LinkID=206669

I have tried exporting and importing settings, deleting relevant suo files to no avail. This happens even when I don't open a solution.

One thing that I have found is that when I open VS the second time, the following config file is correct. C:\Documents and Settings{myusername}\Application Data\NuGet\NuGet.Config

As soon as I open the Package Manager under Tools -> Options, the official source gets added to NuGet.Config so,

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="Local Package Source" 
        value="http://nuget:8081/DataServices/Packages.svc/" />
  </packageSources>
  <activePackageSource>
    <add key="All" value="(Aggregate source)" />
  </activePackageSource>
</configuration

Is changed to...

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <!-- new line below -->
    <add key="NuGet official package source" 
        value="https://go.microsoft.com/fwlink/?LinkID=206669" />
    <add key="Local Package Source" 
        value="http://nuget:8081/DataServices/Packages.svc/" />
  </packageSources>
  <activePackageSource>
    <add key="All" value="(Aggregate source)" />
  </activePackageSource>
</configuration

This file doesn't get changed when the Options dialog opens, just when I click on the Package Manager in the Options tree view.

Where is it getting this setting from and why does it keep inserting it?

Update copied from Ben Phegan on same issue on CodePlex

http://nuget.codeplex.com/workitem/1696

"I think this might be an issue with the implementation of AddOfficialPackageSourceIfNeeded() here"... http://nuget.codeplex.com/SourceControl/changeset/view/2b36b2e1935a#src%2fVisualStudio%2fPackageSource%2fVSPackageSourceProvider.cs

1条回答
该账号已被封号
2楼-- · 2019-08-28 02:40

There is some code within the NuGet vsix itself that adds the default feed back if there are no others in the list, but it appears that there is a bug in it:

    if (officialFeed == null)
    {
        // There is no official feed currently registered

        // Don't register our feed unless the list is empty (other than the aggregate). This is the first-run scenario.
        // It also applies if user deletes all their feeds, in which case bringing back the official feed makes sense.
        if (_packageSources.Count > 1)
        {
            return;
        }

    }

This then falls through and adds the official feed as the first source. I would add another source so that you have >1 source (a local directory should work). This should prevent this behaviour.

The Nuget.exe command has similar behaviour, however it is added by default regardless of the sources available.

I believe this behaviour does differ by version. What version are you using?

查看更多
登录 后发表回答