Skip to content

Commit 00df236

Browse files
committed
- Issue #202: Better versioning of referenced NuGet packages
1 parent 1608239 commit 00df236

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

Source/NuGet.cs

+22-7
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,30 @@ static IEnumerable<PackageInfo> ResolveDependenciesFor(IEnumerable<PackageInfo>
123123
var result = new List<PackageInfo>();
124124
var map = new Dictionary<string, List<PackageInfo>>();
125125

126-
foreach (var p in packages)
127-
foreach (var nupkg in Directory.GetFiles(p.SpecFile.GetDirName().GetDirName(), "*.nupkg", SearchOption.AllDirectories))
126+
void add(PackageInfo info)
127+
{
128+
if (!map.ContainsKey(info.Name))
129+
map[info.Name] = new List<PackageInfo>();
130+
map[info.Name].Add(info);
131+
}
132+
133+
foreach (var parentPackage in packages)
134+
{
135+
add(parentPackage);
136+
137+
foreach (var nupkg in Directory.GetFiles(parentPackage.SpecFile.GetDirName().GetDirName(), "*.nupkg", SearchOption.AllDirectories))
128138
{
129139
var info = ExtractPackageInfo(nupkg);
130-
info.PreferredRuntime = p.PreferredRuntime;
131140

132-
if (!map.ContainsKey(info.Name))
133-
map[info.Name] = new List<PackageInfo>();
141+
// if user requested a specific version, then do not interfere and ignore other packages with the same
142+
// name but potentially different version
143+
if (info.Name == parentPackage.Name && parentPackage.Version.HasText())
144+
continue;
134145

135-
map[info.Name].Add(info);
146+
info.PreferredRuntime = parentPackage.PreferredRuntime;
147+
add(info);
136148
}
149+
}
137150

138151
foreach (var key in map.Keys)
139152
{
@@ -344,7 +357,9 @@ static public string[] Resolve(string[] packages, bool suppressDownloading, stri
344357
newPackageWasInstalled = true;
345358
sw.Stop();
346359
}
347-
catch { }
360+
catch (Exception e)
361+
{
362+
}
348363

349364
try
350365
{

0 commit comments

Comments
 (0)