Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/NuGetReferenceSwitcher.Presentation/Models/ProjectModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System.Linq;
using System.Windows.Threading;
using System.Xml;
using System.Xml.Linq;
using EnvDTE;
using MyToolkit.Collections;
using VSLangProj;
Expand Down Expand Up @@ -164,8 +165,28 @@ private void LoadReferences()
NuGetReferences = new ExtendedObservableCollection<ReferenceModel>();

List<string> packageDirs = new List<string>();
packageDirs.Add("/packages/");
packageDirs.Add("\\packages\\");

// Check if the NuGet.Config file has a repository path set and use it
var nugetSettingsPath =
System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NuGet",
"NuGet.Config");
var configRepositoryPathOverride = false;
if (File.Exists(nugetSettingsPath))
{
var repositoryPath = (string)XElement.Load(nugetSettingsPath).Descendants("add").FirstOrDefault(add => (string)add.Attribute("key") == "repositoryPath")?.Attribute("value");
if (repositoryPath != null)
{
packageDirs.Add(repositoryPath);
configRepositoryPathOverride = true;
}
}

// If the Nuget.Config file has not repository path set then use default paths
if (!configRepositoryPathOverride)
{
packageDirs.Add("/packages/");
packageDirs.Add("\\packages\\");
}

if (SolutionFile.Exists)
{
Expand Down