diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000000..758d1c575c --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,6 @@ + + + + + + diff --git a/Directory.Build.targets b/Directory.Build.targets new file mode 100644 index 0000000000..692f3a81da --- /dev/null +++ b/Directory.Build.targets @@ -0,0 +1,6 @@ + + + $(MicrosoftNETCoreApp21PackageVersion) + $(NETStandardLibrary20PackageVersion) + + diff --git a/Microsoft.AspNetCore.sln b/Microsoft.AspNetCore.sln new file mode 100644 index 0000000000..809b017e25 --- /dev/null +++ b/Microsoft.AspNetCore.sln @@ -0,0 +1,39 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26124.0 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{EE2CAA71-82AA-41C0-AE87-5B4FB77D6CFE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharedFx.UnitTests", "test\SharedFx.UnitTests\SharedFx.UnitTests.csproj", "{99CC38EC-902B-4B3F-AD33-177018110199}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {99CC38EC-902B-4B3F-AD33-177018110199}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {99CC38EC-902B-4B3F-AD33-177018110199}.Debug|Any CPU.Build.0 = Debug|Any CPU + {99CC38EC-902B-4B3F-AD33-177018110199}.Debug|x64.ActiveCfg = Debug|Any CPU + {99CC38EC-902B-4B3F-AD33-177018110199}.Debug|x64.Build.0 = Debug|Any CPU + {99CC38EC-902B-4B3F-AD33-177018110199}.Debug|x86.ActiveCfg = Debug|Any CPU + {99CC38EC-902B-4B3F-AD33-177018110199}.Debug|x86.Build.0 = Debug|Any CPU + {99CC38EC-902B-4B3F-AD33-177018110199}.Release|Any CPU.ActiveCfg = Release|Any CPU + {99CC38EC-902B-4B3F-AD33-177018110199}.Release|Any CPU.Build.0 = Release|Any CPU + {99CC38EC-902B-4B3F-AD33-177018110199}.Release|x64.ActiveCfg = Release|Any CPU + {99CC38EC-902B-4B3F-AD33-177018110199}.Release|x64.Build.0 = Release|Any CPU + {99CC38EC-902B-4B3F-AD33-177018110199}.Release|x86.ActiveCfg = Release|Any CPU + {99CC38EC-902B-4B3F-AD33-177018110199}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {99CC38EC-902B-4B3F-AD33-177018110199} = {EE2CAA71-82AA-41C0-AE87-5B4FB77D6CFE} + EndGlobalSection +EndGlobal diff --git a/build/SharedFx.targets b/build/SharedFx.targets index 3abd1b30e5..ed0bb6cf96 100644 --- a/build/SharedFx.targets +++ b/build/SharedFx.targets @@ -197,7 +197,7 @@ - + @@ -528,6 +528,21 @@ Overwrite="true"/> - + + + + + $(RepositoryRoot)\test\SharedFx.UnitTests\SharedFx.UnitTests.csproj + + DotNetRestoreSourcePropsPath=$(GeneratedRestoreSourcesPropsPath); + DotNetPackageVersionPropsPath=$(GeneratedPackageVersionPropsPath); + SharedFxOutputPath=$(SharedFxIntermediateOutputPath); + RepositoryCommit=$(RepositoryCommit); + SharedFxRuntimeIdentifier=$(SharedFXRid) + + + + + diff --git a/build/common.props b/build/common.props index 6552ad98ea..b34f91a0b1 100644 --- a/build/common.props +++ b/build/common.props @@ -11,8 +11,4 @@ true - - - - diff --git a/build/dependencies.props b/build/dependencies.props index e86f1495f9..119224bdb4 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -11,6 +11,7 @@ $(MicrosoftNETCoreAppPackageVersion) + $(MicrosoftNETCoreApp21PackageVersion) $(KoreBuildVersion) diff --git a/build/tasks/RepoTasks.csproj b/build/tasks/RepoTasks.csproj index 7c95128fdd..6be1f375d2 100644 --- a/build/tasks/RepoTasks.csproj +++ b/build/tasks/RepoTasks.csproj @@ -1,7 +1,5 @@ - - netcoreapp2.0 diff --git a/build/tools/templates/Archive/Archive.csproj b/build/tools/templates/Archive/Archive.csproj index e993fa7126..e2843be0e0 100644 --- a/build/tools/templates/Archive/Archive.csproj +++ b/build/tools/templates/Archive/Archive.csproj @@ -1,12 +1,8 @@ - - netcoreapp2.1 false - netcoreapp2.1 - $(RestoreSources);$(DotNetRestoreSources); true true diff --git a/build/tools/templates/SharedFx/SharedFx.csproj b/build/tools/templates/SharedFx/SharedFx.csproj index 24bd3aad7e..14e621ae49 100644 --- a/build/tools/templates/SharedFx/SharedFx.csproj +++ b/build/tools/templates/SharedFx/SharedFx.csproj @@ -1,12 +1,9 @@ - - - + netcoreapp2.1 true true - $(RestoreSources);$(DotNetRestoreSources); diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 79ca86d0bb..34fdc31455 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,6 +1,7 @@ - - - - + + + + + diff --git a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj index 6df70d6f22..25ed991894 100644 --- a/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj +++ b/src/Microsoft.AspNetCore.All/Microsoft.AspNetCore.All.csproj @@ -1,7 +1,5 @@ - - false false diff --git a/src/Microsoft.AspNetCore.Analyzers/Microsoft.AspNetCore.Analyzers.csproj b/src/Microsoft.AspNetCore.Analyzers/Microsoft.AspNetCore.Analyzers.csproj index 5927d10ad9..a9f9071719 100644 --- a/src/Microsoft.AspNetCore.Analyzers/Microsoft.AspNetCore.Analyzers.csproj +++ b/src/Microsoft.AspNetCore.Analyzers/Microsoft.AspNetCore.Analyzers.csproj @@ -1,7 +1,5 @@ - - false false diff --git a/src/Microsoft.AspNetCore.App/Microsoft.AspNetCore.App.csproj b/src/Microsoft.AspNetCore.App/Microsoft.AspNetCore.App.csproj index d87e940d0c..25e863ae37 100644 --- a/src/Microsoft.AspNetCore.App/Microsoft.AspNetCore.App.csproj +++ b/src/Microsoft.AspNetCore.App/Microsoft.AspNetCore.App.csproj @@ -1,7 +1,5 @@ - - false false diff --git a/test/SharedFx.UnitTests/AssertEx.cs b/test/SharedFx.UnitTests/AssertEx.cs new file mode 100644 index 0000000000..c68147c1f6 --- /dev/null +++ b/test/SharedFx.UnitTests/AssertEx.cs @@ -0,0 +1,35 @@ +// 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.IO; +using Xunit.Sdk; + +namespace Microsoft.AspNetCore +{ + public class AssertEx + { + public static void DirectoryExists(string path) + { + if (!Directory.Exists(path)) + { + throw new XunitException($"Expected directory to exist at {path} but it did not"); + } + } + + public static void FileExists(string path) + { + if (!File.Exists(path)) + { + throw new XunitException($"Expected file to exist at {path} but it did not"); + } + } + + public static void FileDoesNotExists(string path) + { + if (File.Exists(path)) + { + throw new XunitException($"File should not exist at {path}"); + } + } + } +} diff --git a/test/SharedFx.UnitTests/SharedFx.UnitTests.csproj b/test/SharedFx.UnitTests/SharedFx.UnitTests.csproj new file mode 100644 index 0000000000..31a39f032c --- /dev/null +++ b/test/SharedFx.UnitTests/SharedFx.UnitTests.csproj @@ -0,0 +1,39 @@ + + + + netcoreapp2.1 + Microsoft.AspNetCore + + + + + <_Parameter1>PackageVersion + <_Parameter2>$(PackageVersion) + + + <_Parameter1>DotNetRoot + <_Parameter2>$(SharedFxOutputPath) + + + <_Parameter1>SharedFxRuntimeIdentifier + <_Parameter2>$(SharedFxRuntimeIdentifier) + + + <_Parameter1>RepositoryCommit + <_Parameter2>$(RepositoryCommit) + + + <_Parameter1>MicrosoftNETCoreAppPackageVersion + <_Parameter2>$(MicrosoftNETCoreAppPackageVersion) + + + + + + + + + + + + diff --git a/test/SharedFx.UnitTests/SharedFxTests.cs b/test/SharedFx.UnitTests/SharedFxTests.cs new file mode 100644 index 0000000000..d18fa17ef8 --- /dev/null +++ b/test/SharedFx.UnitTests/SharedFxTests.cs @@ -0,0 +1,97 @@ +// 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.IO; +using Newtonsoft.Json.Linq; +using Xunit; + +namespace Microsoft.AspNetCore +{ + public class SharedFxTests + { + [Theory] + [MemberData(nameof(GetSharedFxConfig))] + public void ItContainsValidRuntimeConfigFile(SharedFxConfig config) + { + var root = TestData.GetDotNetRoot(); + var dir = Path.Combine(root, "shared", config.Name, config.Version); + var runtimeConfigFilePath = Path.Combine(dir, config.Name + ".runtimeconfig.json"); + + AssertEx.FileExists(runtimeConfigFilePath); + AssertEx.FileDoesNotExists(Path.Combine(dir, config.Name + ".runtimeconfig.dev.json")); + + var runtimeConfig = JObject.Parse(File.ReadAllText(runtimeConfigFilePath)); + + Assert.Equal(config.BaseSharedFxName, (string)runtimeConfig["runtimeOptions"]["framework"]["name"]); + Assert.Equal("netcoreapp" + config.Version.Substring(0, 3), (string)runtimeConfig["runtimeOptions"]["tfm"]); + + Assert.Equal(config.BaseSharedFxVersion, (string)runtimeConfig["runtimeOptions"]["framework"]["version"]); + } + + [Theory] + [MemberData(nameof(GetSharedFxConfig))] + public void ItContainsValidDepsJson(SharedFxConfig config) + { + var root = TestData.GetDotNetRoot(); + var dir = Path.Combine(root, "shared", config.Name, config.Version); + var depsFilePath = Path.Combine(dir, config.Name + ".deps.json"); + + var target = $".NETCoreApp,Version=v{config.Version.Substring(0, 3)}/{config.RuntimeIdentifier}"; + + AssertEx.FileExists(depsFilePath); + + var depsFile = JObject.Parse(File.ReadAllText(depsFilePath)); + + Assert.Equal(target, (string)depsFile["runtimeTarget"]["name"]); + Assert.NotNull(depsFile["targets"][target]); + Assert.NotNull(depsFile["compilationOptions"]); + Assert.Empty(depsFile["compilationOptions"]); + Assert.NotEmpty(depsFile["runtimes"][config.RuntimeIdentifier]); + } + + [Theory] + [MemberData(nameof(GetSharedFxConfig))] + public void ItContainsVersionFile(SharedFxConfig config) + { + var root = TestData.GetDotNetRoot(); + var versionFile = Path.Combine(root, "shared", config.Name, config.Version, ".version"); + AssertEx.FileExists(versionFile); + var lines = File.ReadAllLines(versionFile); + Assert.Equal(2, lines.Length); + Assert.Equal(TestData.GetRepositoryCommit(), lines[0]); + Assert.Equal(config.Version, lines[1]); + } + + + public static TheoryData GetSharedFxConfig() + => new TheoryData + { + new SharedFxConfig + { + Name = "Microsoft.AspNetCore.All", + Version = TestData.GetPackageVersion(), + // Intentionally assert aspnetcore frameworks align versions with each other and netcore + BaseSharedFxVersion = TestData.GetPackageVersion(), + BaseSharedFxName = "Microsoft.AspNetCore.App", + RuntimeIdentifier = TestData.GetSharedFxRuntimeIdentifier(), + }, + new SharedFxConfig + { + Name = "Microsoft.AspNetCore.App", + Version = TestData.GetPackageVersion(), + BaseSharedFxName = "Microsoft.NETCore.App", + BaseSharedFxVersion = TestData.GetMicrosoftNETCoreAppPackageVersion(), + RuntimeIdentifier = TestData.GetSharedFxRuntimeIdentifier(), + }, + }; + + public class SharedFxConfig + { + public string Name { get; set; } + public string Version { get; set; } + public string BaseSharedFxName { get; set; } + public string BaseSharedFxVersion { get; set; } + public string RuntimeIdentifier { get; set; } + } + } +} diff --git a/test/SharedFx.UnitTests/TestData.cs b/test/SharedFx.UnitTests/TestData.cs new file mode 100644 index 0000000000..eb01f60e8b --- /dev/null +++ b/test/SharedFx.UnitTests/TestData.cs @@ -0,0 +1,24 @@ +// 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.Linq; +using System.Reflection; + +namespace Microsoft.AspNetCore +{ + public class TestData + { + public static string GetPackageVersion() => GetTestDataValue("PackageVersion"); + + public static string GetMicrosoftNETCoreAppPackageVersion() => GetTestDataValue("MicrosoftNETCoreAppPackageVersion"); + + public static string GetDotNetRoot() => GetTestDataValue("DotNetRoot"); + + public static string GetRepositoryCommit() => GetTestDataValue("RepositoryCommit"); + + public static string GetSharedFxRuntimeIdentifier() => GetTestDataValue("SharedFxRuntimeIdentifier"); + + private static string GetTestDataValue(string key) + => typeof(TestData).Assembly.GetCustomAttributes().Single(d => d.Key == key).Value; + } +} diff --git a/test/SharedFx.UnitTests/TestDataAttribute.cs b/test/SharedFx.UnitTests/TestDataAttribute.cs new file mode 100644 index 0000000000..68085e6807 --- /dev/null +++ b/test/SharedFx.UnitTests/TestDataAttribute.cs @@ -0,0 +1,20 @@ +// 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; + +namespace Microsoft.AspNetCore +{ + [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] + internal class TestDataAttribute : Attribute + { + public TestDataAttribute(string key, string value) + { + Key = key; + Value = value; + } + + public string Key { get; } + public string Value { get; } + } +} diff --git a/version.props b/version.props index 43106355c0..1652259436 100644 --- a/version.props +++ b/version.props @@ -5,6 +5,7 @@ 3 $(AspNetCoreMajorVersion).$(AspNetCoreMinorVersion).$(AspNetCorePatchVersion) rtm + t000 $(VersionPrefix)