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
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:
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?