From 7c688eea7fe807c9026e1fc59955f59db076c137 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Wed, 20 Apr 2016 11:54:42 -0700 Subject: [PATCH] fix framework assembly resolution for net35 (#2557) --- .../Program.cs | 5 ++++ .../project.json | 25 ++++++++++++++++--- .../Resolution/FrameworkReferenceResolver.cs | 14 +++++------ 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/TestAssets/TestProjects/TestLibraryWithMultipleFrameworks/Program.cs b/TestAssets/TestProjects/TestLibraryWithMultipleFrameworks/Program.cs index f5f4b6d13..bb536dcc4 100644 --- a/TestAssets/TestProjects/TestLibraryWithMultipleFrameworks/Program.cs +++ b/TestAssets/TestProjects/TestLibraryWithMultipleFrameworks/Program.cs @@ -1,4 +1,5 @@ using System; +using System.Xml; namespace ConsoleApplication { @@ -7,6 +8,10 @@ namespace ConsoleApplication public static void Main() { Console.WriteLine("Hello World!"); +#if NET20 || NET35 || NET45 || NET461 + // Force XmlDocument to be used + var doc = new XmlDocument(); +#endif } } } diff --git a/TestAssets/TestProjects/TestLibraryWithMultipleFrameworks/project.json b/TestAssets/TestProjects/TestLibraryWithMultipleFrameworks/project.json index fe6bff5f3..b640e4e13 100644 --- a/TestAssets/TestProjects/TestLibraryWithMultipleFrameworks/project.json +++ b/TestAssets/TestProjects/TestLibraryWithMultipleFrameworks/project.json @@ -5,11 +5,28 @@ }, "dependencies": {}, "frameworks": { - "net20": {}, - "net35": {}, - "net40": {}, - "net461": {}, + "net20": { + "frameworkAssemblies": { + "System.Xml": {} + } + }, + "net35": { + "frameworkAssemblies": { + "System.Xml": {} + } + }, + "net40": { + "frameworkAssemblies": { + "System.Xml": {} + } + }, + "net461": { + "frameworkAssemblies": { + "System.Xml": {} + } + }, "netstandard1.5": { + "imports": "dnxcore50", "dependencies": { "NETStandard.Library": "1.5.0-rc2-24018" } diff --git a/src/Microsoft.DotNet.ProjectModel/Resolution/FrameworkReferenceResolver.cs b/src/Microsoft.DotNet.ProjectModel/Resolution/FrameworkReferenceResolver.cs index e75860ed1..e5c605730 100644 --- a/src/Microsoft.DotNet.ProjectModel/Resolution/FrameworkReferenceResolver.cs +++ b/src/Microsoft.DotNet.ProjectModel/Resolution/FrameworkReferenceResolver.cs @@ -20,7 +20,7 @@ namespace Microsoft.DotNet.ProjectModel.Resolution private static readonly NuGetFramework Dnx46 = new NuGetFramework( FrameworkConstants.FrameworkIdentifiers.Dnx, new Version(4, 6)); - + private static FrameworkReferenceResolver _default; private readonly IDictionary _cache = new Dictionary(); @@ -30,14 +30,14 @@ namespace Microsoft.DotNet.ProjectModel.Resolution { FrameworkConstants.CommonFrameworks.Dnx451, new [] { FrameworkConstants.CommonFrameworks.Net451 } }, { Dnx46, new [] { FrameworkConstants.CommonFrameworks.Net46 } } }; - + public FrameworkReferenceResolver(string referenceAssembliesPath) { ReferenceAssembliesPath = referenceAssembliesPath; } - + public string ReferenceAssembliesPath { get; } - + public static FrameworkReferenceResolver Default { get @@ -46,11 +46,11 @@ namespace Microsoft.DotNet.ProjectModel.Resolution { _default = new FrameworkReferenceResolver(GetDefaultReferenceAssembliesPath()); } - + return _default; } } - + public static string GetDefaultReferenceAssembliesPath() { // Allow setting the reference assemblies path via an environment variable @@ -210,7 +210,7 @@ namespace Microsoft.DotNet.ProjectModel.Resolution // Check for legacy frameworks if (PlatformServices.Default.Runtime.OperatingSystemPlatform == Platform.Windows && targetFramework.IsDesktop() && - targetFramework.Version <= new Version(3, 5)) + targetFramework.Version <= new Version(3, 5, 0, 0)) { return GetLegacyFrameworkInformation(targetFramework, referenceAssembliesPath); }