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

Commit

Permalink
Changed aspnetcore framework compatibility
Browse files Browse the repository at this point in the history
- Updated JSON.NET to 6.0.6
- Removed win8 aliasing and added an temporary ugly heuristic for aspnetcore50
compat
- Added unit tests

#596
  • Loading branch information
davidfowl committed Oct 23, 2014
1 parent 2856ac1 commit e425a29
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 57 deletions.
6 changes: 3 additions & 3 deletions makefile.shade
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ var MSBUILD = '${Path.Combine(PROGRAM_FILES_X86, "MSBuild", "14.0", "Bin", "MSBu

if (framework == "aspnetcore50")
{
candidates = new [] { framework, "netcore45", "win8", "k10" };
candidates = new [] { framework, "windows8+net45+wp8+wpa81", "net45+win8" };

This comment has been minimized.

Copy link
@pranavkm

pranavkm Oct 23, 2014

Contributor

The directory name in NewtonSoft.Json 6.0.5 is portable-net40+sl5+wp80+win8+wpa81. This doesn't work. Plus perhaps this thing needs to be a bit more clever about supporting permutations in which these frameworks appear rather than look for exact path?

This comment has been minimized.

Copy link
@davidfowl

davidfowl Oct 23, 2014

Author Member

Temporary, there's new logic that will remove this check completely:

#775

This new code will be used to get the correct set of paths based on what was resolved during the build

}
else
{
Expand Down Expand Up @@ -483,7 +483,7 @@ var MSBUILD = '${Path.Combine(PROGRAM_FILES_X86, "MSBuild", "14.0", "Bin", "MSBu
string packageFileDest = Path.Combine(targetDir, fi.Name);
File.Copy(fi.FullName, packageFileDest, true);

Log.Info("Copying to " + packageFileDest);
Log.Info("Copying from " + fi.FullName + " to " + packageFileDest);
}
}
}
Expand All @@ -506,7 +506,7 @@ var MSBUILD = '${Path.Combine(PROGRAM_FILES_X86, "MSBuild", "14.0", "Bin", "MSBu
continue;
}

string[] candidates = new [] { "aspnetcore50", "k10", "netcore45", "win8" };
var candidates = new [] { "aspnetcore50", "windows8+net45+wp8+wpa81", "net45+win8" };

var lib = new DirectoryInfo(Path.Combine(packageDir, "lib"));
var di = candidates.Select(fmk => lib.EnumerateDirectories("*" + fmk+ "*")
Expand Down
6 changes: 0 additions & 6 deletions samples/HelloShared/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
"shared": "*.cs",
"frameworks": {
"net45": { },
"k10": {
"dependencies": {
"System.Linq": "4.0.0-beta-*",
"System.Runtime": "4.0.20-beta-*"
}
},
"aspnet50": { },
"aspnetcore50": {
"dependencies": {
Expand Down
11 changes: 1 addition & 10 deletions samples/HelloWorld/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@
"System.Text.Encoding": ""
}
},
"k10": {
"dependencies": {
"System.Console": "4.0.0-beta-*",
"System.Linq": "4.0.0-beta-*",
"System.Reflection": "4.0.10-beta-*",
"System.Runtime": "4.0.20-beta-*",
"System.Threading.Tasks": "4.0.10-beta-*",
"System.ComponentModel": "4.0.0-beta-*"
}
},
"aspnet50": {
"frameworkAssemblies": {
"System.Collections": "",
Expand All @@ -44,6 +34,7 @@
},
"aspnetcore50": {
"dependencies": {
"System.IO": "4.0.10-beta-*",
"System.Console": "4.0.0-beta-*",
"System.Linq": "4.0.0-beta-*",
"System.Reflection": "4.0.10-beta-*",
Expand Down
6 changes: 3 additions & 3 deletions src/Microsoft.Framework.DesignTimeHost/project.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "1.0.0-*",
"dependencies": {
"Newtonsoft.Json": "6.0.4",
"Newtonsoft.Json": "6.0.6",

This comment has been minimized.

Copy link
@pranavkm

pranavkm Oct 23, 2014

Contributor

The latest package on NuGet.org is 6.0.5. http://www.nuget.org/packages/Newtonsoft.Json/
Was this intentional?

This comment has been minimized.

Copy link
@victorhurdugaci

victorhurdugaci Oct 23, 2014

Contributor

https://www.myget.org/gallery/aspnetvnext it is 6.0.6. We have some private bits.

"Microsoft.Framework.Runtime": "1.0.0-*",
"Microsoft.Framework.Runtime.Common": { "version": "1.0.0-*", "type": "build" },
"Microsoft.Framework.Runtime.Interfaces": { "version": "1.0.0-*", "type": "build" },
Expand Down Expand Up @@ -37,8 +37,8 @@
},
"scripts": {
"postbuild": [
"xcopy /F /Y /I bin\\Debug\\net45\\*.* ..\\..\\artifacts\\build\\KRE-CLR-x86\\bin",
"xcopy /F /Y /I bin\\Debug\\aspnetcore50\\*.* ..\\..\\artifacts\\build\\KRE-CoreCLR-x86\\bin"
"xcopy /F /Y /I bin\\Debug\\net45\\*.* ..\\..\\artifacts\\build\\KRE-CLR-x86\\bin\\lib\\Microsoft.Framework.DesignTimeHost",
"xcopy /F /Y /I bin\\Debug\\aspnetcore50\\*.* ..\\..\\artifacts\\build\\KRE-CoreCLR-x86\\bin\\lib\\Microsoft.Framework.DesignTimeHost"
]
}
}
18 changes: 10 additions & 8 deletions src/Microsoft.Framework.Runtime.Interfaces/project.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{
"version": "1.0.0-*",
"compilationOptions" : { "warningsAsErrors": true },
"frameworks" : {
"net45" : { },
"aspnetcore50" : {
"compilationOptions": { "warningsAsErrors": true },
"frameworks": {
"net45": { },
"aspnetcore50": {
"dependencies": {
"System.ComponentModel": "4.0.0-beta-*",
"System.Reflection" : "4.0.10-beta-*",
"System.Runtime" : "4.0.20-beta-*",
"System.Runtime.Extensions" : "4.0.10-beta-*"
"System.IO": "4.0.10-beta-*",
"System.Reflection": "4.0.10-beta-*",
"System.Runtime": "4.0.20-beta-*",
"System.Runtime.Extensions": "4.0.10-beta-*",
"System.Threading.Tasks": "4.0.10-beta-*",
"System.ComponentModel": "4.0.0-beta-*"
}
}
}
Expand Down
43 changes: 23 additions & 20 deletions src/Microsoft.Framework.Runtime/NuGet/Utility/VersionUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,13 @@ public static class VersionUtility

{ new FrameworkName("Windows, Version=v0.0"), new FrameworkName(".NETCore, Version=v4.5") },
{ new FrameworkName("Windows, Version=v8.0"), new FrameworkName(".NETCore, Version=v4.5") },
{ new FrameworkName("Windows, Version=v8.1"), new FrameworkName(".NETCore, Version=v4.5.1") },
{ new FrameworkName(AspNetCoreFrameworkIdentifier, new Version(5, 0)), new FrameworkName("K", new Version(1, 0)) }
{ new FrameworkName("Windows, Version=v8.1"), new FrameworkName(".NETCore, Version=v4.5.1") }
};

private static readonly Version MaxVersion = new Version(Int32.MaxValue, Int32.MaxValue, Int32.MaxValue, Int32.MaxValue);
private static readonly Dictionary<string, FrameworkName> _equivalentProjectFrameworks = new Dictionary<string, FrameworkName>()
{
{ AspNetFrameworkIdentifier, new FrameworkName(NetFrameworkIdentifier, MaxVersion) },

{ AspNetCoreFrameworkIdentifier, new FrameworkName(NetCoreFrameworkIdentifier, MaxVersion) },

// Temporary backwards compatiblity .NETCore
{ "K", new FrameworkName(NetCoreFrameworkIdentifier, MaxVersion) },
{ AspNetFrameworkIdentifier, new FrameworkName(NetFrameworkIdentifier, MaxVersion) }
};

public static Version DefaultTargetFrameworkVersion
Expand All @@ -119,17 +113,6 @@ public static FrameworkName DefaultTargetFramework
}
}

internal static FrameworkName GetEquivalentFramework(FrameworkName targetFramework)
{
FrameworkName equivalentFramework;
if (_equivalentProjectFrameworks.TryGetValue(targetFramework.Identifier, out equivalentFramework))
{
return equivalentFramework;
}

return null;
}

public static bool IsDesktop(FrameworkName frameworkName)
{
return frameworkName.Identifier == NetFrameworkIdentifier ||
Expand Down Expand Up @@ -853,7 +836,27 @@ private static bool IsPortableLibraryCompatible(FrameworkName frameworkName, Fra
else
{
// this is the case with Portable Library installed into a normal project
return targetFrameworkPortableProfile.IsCompatibleWith(frameworkName);
bool isCompatible = targetFrameworkPortableProfile.IsCompatibleWith(frameworkName);

if (!isCompatible)
{
// TODO: Remove this logic when out dependencies have moved to ASP.NET Core 5.0
// as this logic is super fuzzy and terrible
if (string.Equals(frameworkName.Identifier, AspNetCoreFrameworkIdentifier, StringComparison.OrdinalIgnoreCase))
{
var frameworkIdentifierLookup = targetFrameworkPortableProfile.SupportedFrameworks
.Select(NormalizeFrameworkName)
.ToLookup(f => f.Identifier);

if (frameworkIdentifierLookup[NetFrameworkIdentifier].Any(f => f.Version >= new Version(4, 5)) &&
frameworkIdentifierLookup[NetCoreFrameworkIdentifier].Any(f => f.Version >= new Version(4, 5)))
{
return true;
}
}
}

return isCompatible;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Framework.Runtime/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"Microsoft.Framework.Runtime.Loader": "1.0.0-*",
"Microsoft.Framework.Runtime.Common": { "version": "1.0.0-*", "type": "build" },
"Microsoft.Framework.Runtime.Interfaces": { "version": "1.0.0-*", "type": "build" },
"Newtonsoft.Json": "6.0.4"
"Newtonsoft.Json": "6.0.6"
},
"frameworks": {
"net45": {
Expand Down
23 changes: 17 additions & 6 deletions test/Microsoft.Framework.Runtime.Tests/VersionUtilityFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,25 @@ namespace Microsoft.Framework.Runtime.Tests
public class VersionUtilityFacts
{
[Theory]
[InlineData("aspnetcore50", "k10", true)]
[InlineData("k10", "aspnetcore50", true)]
[InlineData("aspnet50", "net45", true)]
[InlineData("net45", "aspnet50", false)]
public void FrameworksAreCompatible(string targetFramework1, string targetFramework2, bool compatible)
[InlineData("aspnet50", "net45", true)]
[InlineData("aspnetcore50", "k10", false)]
[InlineData("k10", "aspnetcore50", false)]
[InlineData("netcore45", "aspnetcore50", false)]
[InlineData("win8", "aspnetcore50", false)]
[InlineData("win81", "aspnetcore50", false)]
[InlineData("aspnetcore50", "netcore45", false)]
[InlineData("aspnetcore50", "win8", false)]
[InlineData("aspnetcore50", "win81", false)]
[InlineData("aspnetcore50", "portable-net40+win8+aspnetcore50", true)]
// Temporary until our dependencies update
[InlineData("aspnetcore50", "portable-net45+win8", true)]
[InlineData("aspnetcore50", "portable-net451+win81", true)]
[InlineData("aspnetcore50", "portable-net40+sl5+win8", false)]
public void FrameworksAreCompatible(string projectTargetFramework, string packageTargetFramework, bool compatible)
{
var frameworkName1 = VersionUtility.ParseFrameworkName(targetFramework1);
var frameworkName2 = VersionUtility.ParseFrameworkName(targetFramework2);
var frameworkName1 = VersionUtility.ParseFrameworkName(projectTargetFramework);
var frameworkName2 = VersionUtility.ParseFrameworkName(packageTargetFramework);

var result = VersionUtility.IsCompatible(frameworkName1, frameworkName2);

Expand Down

0 comments on commit e425a29

Please sign in to comment.