Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Commit

Permalink
fix #1894 by adding support for net20
Browse files Browse the repository at this point in the history
  • Loading branch information
analogrelay committed Aug 19, 2015
1 parent 6e8653e commit 7e72d10
Show file tree
Hide file tree
Showing 11 changed files with 445 additions and 90 deletions.
3 changes: 3 additions & 0 deletions src/Microsoft.Dnx.Runtime.Sources/Impl/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ internal static class Constants

public static readonly TimeSpan RegexMatchTimeout = TimeSpan.FromSeconds(10);
public static readonly string AppConfigurationFileName = "app.config";

public static readonly Version Version35 = new Version(3, 5);
public static readonly Version Version40 = new Version(4, 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public IEnumerable<string> GetAttemptedPaths(FrameworkName targetFramework)
return Enumerable.Empty<string>();
}

return GetGacSearchPaths().Select(p => Path.Combine(p, "{name}", "{version}", "{name}.dll"));
return GetGacSearchPaths(targetFramework).Select(p => Path.Combine(p, "{name}", "{version}", "{name}.dll"));
}

public LibraryDescription GetDescription(LibraryRange libraryRange, FrameworkName targetFramework)
Expand All @@ -48,7 +48,7 @@ public LibraryDescription GetDescription(LibraryRange libraryRange, FrameworkNam
var version = libraryRange.VersionRange?.MinVersion;

string path;
if (!TryResolvePartialName(libraryRange.GetReferenceAssemblyName(), version, out path))
if (!TryResolvePartialName(libraryRange.GetReferenceAssemblyName(), version, targetFramework, out path))
{
return null;
}
Expand All @@ -63,9 +63,9 @@ public LibraryDescription GetDescription(LibraryRange libraryRange, FrameworkNam
framework: null);
}

private bool TryResolvePartialName(string name, SemanticVersion version, out string assemblyLocation)
private bool TryResolvePartialName(string name, SemanticVersion version, FrameworkName targetFramework, out string assemblyLocation)
{
foreach (var gacPath in GetGacSearchPaths())
foreach (var gacPath in GetGacSearchPaths(targetFramework))
{
var di = new DirectoryInfo(Path.Combine(gacPath, name));

Expand Down Expand Up @@ -94,18 +94,27 @@ private bool TryResolvePartialName(string name, SemanticVersion version, out str
return false;
}

private static IEnumerable<string> GetGacSearchPaths()
private static IEnumerable<string> GetGacSearchPaths(FrameworkName targetFramework)
{
var gacFolders = new[] { "GAC_32", "GAC_64", "GAC_MSIL" };

string windowsFolder = Environment.GetEnvironmentVariable("WINDIR");

string gacRoot;
if (targetFramework.Version.Major < 4)
{
// Old GAC root
gacRoot = Path.Combine(windowsFolder, "assembly");
}
else
{
// New GAC root
gacRoot = Path.Combine(windowsFolder, "Microsoft.NET", "assembly");
}

foreach (var folder in gacFolders)
{
yield return Path.Combine(windowsFolder,
"Microsoft.NET",
"assembly",
folder);
yield return Path.Combine(gacRoot, folder);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -56,15 +57,21 @@ public LibraryDescription GetDescription(LibraryRange libraryRange, FrameworkNam
LibraryRange = new LibraryRange("System", frameworkReference: true)
});

targetFrameworkDependencies.Add(new LibraryDependency
{
LibraryRange = new LibraryRange("System.Core", frameworkReference: true)
});

targetFrameworkDependencies.Add(new LibraryDependency
if (targetFramework.Version >= Constants.Version35)
{
LibraryRange = new LibraryRange("Microsoft.CSharp", frameworkReference: true)
});
targetFrameworkDependencies.Add(new LibraryDependency
{
LibraryRange = new LibraryRange("System.Core", frameworkReference: true)
});

if (targetFramework.Version >= Constants.Version40)
{
targetFrameworkDependencies.Add(new LibraryDependency
{
LibraryRange = new LibraryRange("Microsoft.CSharp", frameworkReference: true)
});
}
}
}

var dependencies = project.Dependencies.Concat(targetFrameworkDependencies).ToList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,7 @@ public ReferenceAssemblyDependencyResolver(FrameworkReferenceResolver frameworkR

public IEnumerable<string> GetAttemptedPaths(FrameworkName targetFramework)
{
string path = FrameworkResolver.GetFrameworkPath(targetFramework);
if (!string.IsNullOrEmpty(path))
{
return new[]
{
Path.Combine(path, "{name}.dll"),
Path.Combine(path, "Facades", "{name}.dll")
};
}

return Enumerable.Empty<string>();
return FrameworkResolver.GetAttemptedPaths(targetFramework);
}

public LibraryDescription GetDescription(LibraryRange libraryRange, FrameworkName targetFramework)
Expand Down
25 changes: 25 additions & 0 deletions src/Microsoft.Dnx.Runtime/FrameworkDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ private static FrameworkInformation PopulateNet46(string referenceAssembliesPath
frameworkInfo.Path = Path.Combine(referenceAssembliesPath, ".NETFramework", "v4.6");
frameworkInfo.RedistListPath = Path.Combine(referenceAssembliesPath, ".NETFramework", "v4.6", "RedistList", "FrameworkList.xml");
frameworkInfo.Name = ".NET Framework 4.6";
frameworkInfo.SearchPaths = new[]
{
frameworkInfo.Path,
Path.Combine(frameworkInfo.Path, "Facades")
};
frameworkInfo.Assemblies["Accessibility"] = new AssemblyEntry { Path = Path.Combine(frameworkInfo.Path, "Accessibility.dll"), Version = new Version(4, 0, 0, 0) };
frameworkInfo.Assemblies["CustomMarshalers"] = new AssemblyEntry { Path = Path.Combine(frameworkInfo.Path, "CustomMarshalers.dll"), Version = new Version(4, 0, 0, 0) };
frameworkInfo.Assemblies["ISymWrapper"] = new AssemblyEntry { Path = Path.Combine(frameworkInfo.Path, "ISymWrapper.dll"), Version = new Version(4, 0, 0, 0) };
Expand Down Expand Up @@ -265,6 +270,11 @@ private static FrameworkInformation PopulateNet452(string referenceAssembliesPat
frameworkInfo.Path = Path.Combine(referenceAssembliesPath, ".NETFramework", "v4.5.2");
frameworkInfo.RedistListPath = Path.Combine(referenceAssembliesPath, ".NETFramework", "v4.5.2", "RedistList", "FrameworkList.xml");
frameworkInfo.Name = ".NET Framework 4.5.2";
frameworkInfo.SearchPaths = new[]
{
frameworkInfo.Path,
Path.Combine(frameworkInfo.Path, "Facades")
};
frameworkInfo.Assemblies["Accessibility"] = new AssemblyEntry { Path = Path.Combine(frameworkInfo.Path, "Accessibility.dll"), Version = new Version(4, 0, 0, 0) };
frameworkInfo.Assemblies["CustomMarshalers"] = new AssemblyEntry { Path = Path.Combine(frameworkInfo.Path, "CustomMarshalers.dll"), Version = new Version(4, 0, 0, 0) };
frameworkInfo.Assemblies["ISymWrapper"] = new AssemblyEntry { Path = Path.Combine(frameworkInfo.Path, "ISymWrapper.dll"), Version = new Version(4, 0, 0, 0) };
Expand Down Expand Up @@ -459,6 +469,11 @@ private static FrameworkInformation PopulateNet451(string referenceAssembliesPat
frameworkInfo.Path = Path.Combine(referenceAssembliesPath, ".NETFramework", "v4.5.1");
frameworkInfo.RedistListPath = Path.Combine(referenceAssembliesPath, ".NETFramework", "v4.5.1", "RedistList", "FrameworkList.xml");
frameworkInfo.Name = ".NET Framework 4.5.1";
frameworkInfo.SearchPaths = new[]
{
frameworkInfo.Path,
Path.Combine(frameworkInfo.Path, "Facades")
};
frameworkInfo.Assemblies["Accessibility"] = new AssemblyEntry { Path = Path.Combine(frameworkInfo.Path, "Accessibility.dll"), Version = new Version(4, 0, 0, 0) };
frameworkInfo.Assemblies["CustomMarshalers"] = new AssemblyEntry { Path = Path.Combine(frameworkInfo.Path, "CustomMarshalers.dll"), Version = new Version(4, 0, 0, 0) };
frameworkInfo.Assemblies["ISymWrapper"] = new AssemblyEntry { Path = Path.Combine(frameworkInfo.Path, "ISymWrapper.dll"), Version = new Version(4, 0, 0, 0) };
Expand Down Expand Up @@ -653,6 +668,11 @@ private static FrameworkInformation PopulateNet45(string referenceAssembliesPath
frameworkInfo.Path = Path.Combine(referenceAssembliesPath, ".NETFramework", "v4.5");
frameworkInfo.RedistListPath = Path.Combine(referenceAssembliesPath, ".NETFramework", "v4.5", "RedistList", "FrameworkList.xml");
frameworkInfo.Name = ".NET Framework 4.5";
frameworkInfo.SearchPaths = new[]
{
frameworkInfo.Path,
Path.Combine(frameworkInfo.Path, "Facades")
};
frameworkInfo.Assemblies["Accessibility"] = new AssemblyEntry { Path = Path.Combine(frameworkInfo.Path, "Accessibility.dll"), Version = new Version(4, 0, 0, 0) };
frameworkInfo.Assemblies["CustomMarshalers"] = new AssemblyEntry { Path = Path.Combine(frameworkInfo.Path, "CustomMarshalers.dll"), Version = new Version(4, 0, 0, 0) };
frameworkInfo.Assemblies["ISymWrapper"] = new AssemblyEntry { Path = Path.Combine(frameworkInfo.Path, "ISymWrapper.dll"), Version = new Version(4, 0, 0, 0) };
Expand Down Expand Up @@ -846,6 +866,11 @@ private static FrameworkInformation PopulateNet40(string referenceAssembliesPath
frameworkInfo.Path = Path.Combine(referenceAssembliesPath, ".NETFramework", "v4.0");
frameworkInfo.RedistListPath = Path.Combine(referenceAssembliesPath, ".NETFramework", "v4.0", "RedistList", "FrameworkList.xml");
frameworkInfo.Name = ".NET Framework 4";
frameworkInfo.SearchPaths = new[]
{
frameworkInfo.Path,
Path.Combine(frameworkInfo.Path, "Facades")
};
frameworkInfo.Assemblies["Accessibility"] = new AssemblyEntry { Path = Path.Combine(frameworkInfo.Path, "Accessibility.dll"), Version = new Version(4, 0, 0, 0) };
frameworkInfo.Assemblies["CustomMarshalers"] = new AssemblyEntry { Path = Path.Combine(frameworkInfo.Path, "CustomMarshalers.dll"), Version = new Version(4, 0, 0, 0) };
frameworkInfo.Assemblies["ISymWrapper"] = new AssemblyEntry { Path = Path.Combine(frameworkInfo.Path, "ISymWrapper.dll"), Version = new Version(4, 0, 0, 0) };
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.Dnx.Runtime/FrameworkInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public bool Exists

public string Path { get; set; }

public IEnumerable<string> SearchPaths { get; set; }

public string RedistListPath { get; set; }

public IDictionary<string, AssemblyEntry> Assemblies { get; private set; }
Expand Down
Loading

0 comments on commit 7e72d10

Please sign in to comment.