diff --git a/build/Microsoft.DotNet.Cli.Prepare.targets b/build/Microsoft.DotNet.Cli.Prepare.targets index 1cc6e9468..d5311419d 100644 --- a/build/Microsoft.DotNet.Cli.Prepare.targets +++ b/build/Microsoft.DotNet.Cli.Prepare.targets @@ -16,7 +16,7 @@ DependsOnTargets="BuildDotnetCliBuildFramework" > - + diff --git a/build_projects/dotnet-cli-build/GetCurrentRuntimeInformation.cs b/build_projects/dotnet-cli-build/GetCurrentRuntimeInformation.cs index dbbeaa0de..76e10d8ab 100644 --- a/build_projects/dotnet-cli-build/GetCurrentRuntimeInformation.cs +++ b/build_projects/dotnet-cli-build/GetCurrentRuntimeInformation.cs @@ -9,6 +9,8 @@ namespace Microsoft.DotNet.Cli.Build { public class GetCurrentRuntimeInformation : Task { + public string OverrideRid { get; set; } + [Output] public string Rid { get; set; } @@ -20,7 +22,7 @@ namespace Microsoft.DotNet.Cli.Build public override bool Execute() { - Rid = RuntimeEnvironment.GetRuntimeIdentifier(); + Rid = string.IsNullOrEmpty(OverrideRid) ? RuntimeEnvironment.GetRuntimeIdentifier() : OverrideRid; Architecture = RuntimeEnvironment.RuntimeArchitecture; OSName = Monikers.GetOSShortName(); diff --git a/src/Microsoft.DotNet.Cli.Utils/Properties/AssemblyInfo.cs b/src/Microsoft.DotNet.Cli.Utils/Properties/AssemblyInfo.cs index e63bf1ff6..7d41c16db 100644 --- a/src/Microsoft.DotNet.Cli.Utils/Properties/AssemblyInfo.cs +++ b/src/Microsoft.DotNet.Cli.Utils/Properties/AssemblyInfo.cs @@ -5,3 +5,4 @@ using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("dotnet, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.DotNet.Tools.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("Microsoft.DotNet.Cli.Utils.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("Microsoft.DotNet.Tools.Tests.Utilities, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] diff --git a/test/EndToEnd/EndToEndTest.cs b/test/EndToEnd/EndToEndTest.cs index 99c3bb9a9..5904a7108 100644 --- a/test/EndToEnd/EndToEndTest.cs +++ b/test/EndToEnd/EndToEndTest.cs @@ -196,7 +196,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd TestProject = Path.Combine(TestDirectory, "project.json"); OutputDirectory = Path.Combine(TestDirectory, s_outputdirName); - Rid = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier(); + Rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier(); } private static void SetupStaticTestProject() diff --git a/test/Microsoft.DotNet.Cli.Utils.Tests/GivenAProjectDependencyCommandResolver.cs b/test/Microsoft.DotNet.Cli.Utils.Tests/GivenAProjectDependencyCommandResolver.cs index b31838b92..3da4cab80 100644 --- a/test/Microsoft.DotNet.Cli.Utils.Tests/GivenAProjectDependencyCommandResolver.cs +++ b/test/Microsoft.DotNet.Cli.Utils.Tests/GivenAProjectDependencyCommandResolver.cs @@ -4,6 +4,7 @@ using System; using System.IO; using FluentAssertions; +using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.InternalAbstractions; using Microsoft.DotNet.ProjectModel; using Microsoft.DotNet.Tools.Test.Utilities; @@ -227,8 +228,8 @@ namespace Microsoft.DotNet.Cli.Utils.Tests var projectContext = ProjectContext.Create( testInstance.Path, FrameworkConstants.CommonFrameworks.NetCoreApp10, - RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers()); - + DotnetRuntimeIdentifiers.InferCurrentRuntimeIdentifiers()); + var depsFilePath = projectContext.GetOutputPaths("Debug", outputPath: outputDir).RuntimeFiles.DepsJson; @@ -267,7 +268,7 @@ namespace Microsoft.DotNet.Cli.Utils.Tests var projectContext = ProjectContext.Create( testInstance.Path, FrameworkConstants.CommonFrameworks.NetCoreApp10, - RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers()); + DotnetRuntimeIdentifiers.InferCurrentRuntimeIdentifiers()); var depsFilePath = projectContext.GetOutputPaths("Debug", buildBasePath).RuntimeFiles.DepsJson; diff --git a/test/Microsoft.DotNet.Cli.Utils.Tests/StreamForwarderTests.cs b/test/Microsoft.DotNet.Cli.Utils.Tests/StreamForwarderTests.cs index b21bf321b..109d7dbf8 100644 --- a/test/Microsoft.DotNet.Cli.Utils.Tests/StreamForwarderTests.cs +++ b/test/Microsoft.DotNet.Cli.Utils.Tests/StreamForwarderTests.cs @@ -13,7 +13,7 @@ namespace StreamForwarderTests { public class StreamForwarderTests : TestBase { - private static readonly string s_rid = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier(); + private static readonly string s_rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier(); public static void Main() { diff --git a/test/Microsoft.DotNet.Cli.Utils.Tests/project.json b/test/Microsoft.DotNet.Cli.Utils.Tests/project.json index dcbb34626..85120b8a8 100644 --- a/test/Microsoft.DotNet.Cli.Utils.Tests/project.json +++ b/test/Microsoft.DotNet.Cli.Utils.Tests/project.json @@ -9,8 +9,12 @@ "../../TestAssets/TestProjects/TestAppWithArgs/*", "../../TestAssets/TestProjects/AppWithDirectAndToolDependency/**/*", "../../TestAssets/TestProjects/AppWithDirectDependency/**/*", - "../../TestAssets/TestProjects/AppWithToolDependency/**/*" - ] + "../../TestAssets/TestProjects/AppWithToolDependency/**/*", + "../../artifacts/*/stage2/sdk/*/.version" + ], + "mappings": { + ".version": "../../artifacts/*/stage2/sdk/*/.version" + } } }, "dependencies": { diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/PublishCommand.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/PublishCommand.cs index 0ea9d233b..f652c7a72 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/PublishCommand.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/PublishCommand.cs @@ -72,7 +72,9 @@ namespace Microsoft.DotNet.Tools.Test.Utilities if (!portable) { - var runtime = string.IsNullOrEmpty(_runtime) ? RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier() : _runtime; + var runtime = string.IsNullOrEmpty(_runtime) ? + DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier() : + _runtime; return Path.Combine(config, framework, runtime, PublishSubfolderName); } else diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/DotnetLegacyRuntimeIdentifiers.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/DotnetLegacyRuntimeIdentifiers.cs new file mode 100644 index 000000000..d12593b21 --- /dev/null +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/DotnetLegacyRuntimeIdentifiers.cs @@ -0,0 +1,30 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Collections.Generic; +using Microsoft.DotNet.Cli.Utils; +using Microsoft.DotNet.InternalAbstractions; +using Microsoft.DotNet.PlatformAbstractions; + +namespace Microsoft.DotNet.Tools.Test.Utilities +{ + public static class DotnetLegacyRuntimeIdentifiers + { + public static string InferLegacyRestoreRuntimeIdentifier() + { + if (RuntimeEnvironment.OperatingSystemPlatform != Platform.Windows) + { + FrameworkDependencyFile fxDepsFile = new FrameworkDependencyFile(); + return fxDepsFile.SupportsCurrentRuntime() ? + RuntimeEnvironment.GetRuntimeIdentifier() : + DotnetFiles.VersionFileObject.BuildRid; + + } + else + { + var arch = RuntimeEnvironment.RuntimeArchitecture.ToLowerInvariant(); + return "win7-" + arch; + } + } + } +} \ No newline at end of file diff --git a/test/dotnet-compile.UnitTests/GivenThatICareAboutScriptVariablesFromAManagedCompiler.cs b/test/dotnet-compile.UnitTests/GivenThatICareAboutScriptVariablesFromAManagedCompiler.cs index cd0f3eb70..d2cd9b000 100644 --- a/test/dotnet-compile.UnitTests/GivenThatICareAboutScriptVariablesFromAManagedCompiler.cs +++ b/test/dotnet-compile.UnitTests/GivenThatICareAboutScriptVariablesFromAManagedCompiler.cs @@ -8,6 +8,7 @@ using FluentAssertions; using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.InternalAbstractions; using Microsoft.DotNet.ProjectModel; +using Microsoft.DotNet.Tools.Test.Utilities; using Moq; using NuGet.Frameworks; using Xunit; @@ -69,7 +70,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests [Fact] public void It_passes_a_RuntimeOutputDir_variable_to_the_pre_compile_scripts_if_rid_is_set_in_the_ProjectContext() { - var rid = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier(); + var rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier(); var fixture = ScriptVariablesFixture.GetFixtureWithRids(rid); fixture.PreCompileScriptVariables.Should().ContainKey("compile:RuntimeOutputDir"); fixture.PreCompileScriptVariables["compile:RuntimeOutputDir"].Should().Be(fixture.RuntimeOutputDir); @@ -128,7 +129,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests [Fact] public void It_passes_a_RuntimeOutputDir_variable_to_the_post_compile_scripts_if_rid_is_set_in_the_ProjectContext() { - var rid = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier(); + var rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier(); var fixture = ScriptVariablesFixture.GetFixtureWithRids(rid); fixture.PostCompileScriptVariables.Should().ContainKey("compile:RuntimeOutputDir"); fixture.PostCompileScriptVariables["compile:RuntimeOutputDir"].Should().Be(fixture.RuntimeOutputDir); diff --git a/test/dotnet-compile.UnitTests/project.json b/test/dotnet-compile.UnitTests/project.json index e6c63052f..30181887f 100644 --- a/test/dotnet-compile.UnitTests/project.json +++ b/test/dotnet-compile.UnitTests/project.json @@ -4,8 +4,12 @@ "keyFile": "../../tools/Key.snk", "copyToOutput": { "include": [ - "../../TestAssets/TestProjects/TestAppWithLibrary/**/*" - ] + "../../TestAssets/TestProjects/TestAppWithLibrary/**/*", + "../../artifacts/*/stage2/sdk/*/.version" + ], + "mappings": { + ".version": "../../artifacts/*/stage2/sdk/*/.version" + } } }, "dependencies": { @@ -29,6 +33,9 @@ "Microsoft.DotNet.ProjectModel": { "target": "project" }, + "Microsoft.DotNet.Tools.Tests.Utilities": { + "target": "project" + }, "xunit": "2.2.0-beta3-build3330", "dotnet-test-xunit": "1.0.0-rc2-350904-49", "moq.netcore": "4.4.0-beta8", diff --git a/test/dotnet-publish.Tests/PublishDesktopTests.cs b/test/dotnet-publish.Tests/PublishDesktopTests.cs index afea20671..272c2e3cf 100644 --- a/test/dotnet-publish.Tests/PublishDesktopTests.cs +++ b/test/dotnet-publish.Tests/PublishDesktopTests.cs @@ -54,7 +54,9 @@ namespace Microsoft.DotNet.Tools.Publish.Tests [InlineData("KestrelDesktop", "http://localhost:20207", "win7-x86", "libuv.dll", false)] public async Task DesktopApp_WithKestrel_WorksWhenPublished(string project, string url, string runtime, string libuvName, bool forceRunnable) { - var runnable = forceRunnable || string.IsNullOrEmpty(runtime) || (RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier().Contains(runtime)); + var runnable = forceRunnable || + string.IsNullOrEmpty(runtime) || + (DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier().Contains(runtime)); var testInstance = GetTestInstance() .WithLockFiles(); diff --git a/test/dotnet-publish.Tests/PublishTests.cs b/test/dotnet-publish.Tests/PublishTests.cs index 8aaf45919..d6f355ae1 100644 --- a/test/dotnet-publish.Tests/PublishTests.cs +++ b/test/dotnet-publish.Tests/PublishTests.cs @@ -58,11 +58,11 @@ namespace Microsoft.DotNet.Tools.Publish.Tests { new object[] { "1", "", "", "", "" }, new object[] { "2", "netcoreapp1.0", "", "", "" }, - new object[] { "3", "", RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier(), "", "" }, + new object[] { "3", "", DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier(), "", "" }, new object[] { "4", "", "", "Release", "" }, new object[] { "5", "", "", "", "some/dir"}, new object[] { "6", "", "", "", "some/dir/with spaces" }, - new object[] { "7", "netcoreapp1.0", RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier(), "Debug", "some/dir" }, + new object[] { "7", "netcoreapp1.0", DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier(), "Debug", "some/dir" }, }; } } @@ -221,7 +221,10 @@ namespace Microsoft.DotNet.Tools.Publish.Tests publishCommand.GetOutputDirectory().Should().HaveFile("Newtonsoft.Json.dll"); publishCommand.GetOutputDirectory().Delete(true); - publishCommand = new PublishCommand(lesserTestProject, "netcoreapp1.0", RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier()); + publishCommand = new PublishCommand( + lesserTestProject, + "netcoreapp1.0", + DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier()); publishCommand.Execute().Should().Pass(); publishCommand.GetOutputDirectory().Should().HaveFile("TestLibraryLesser.dll"); diff --git a/test/dotnet-publish.Tests/project.json b/test/dotnet-publish.Tests/project.json index 96b9044db..e829f23fb 100644 --- a/test/dotnet-publish.Tests/project.json +++ b/test/dotnet-publish.Tests/project.json @@ -1,5 +1,15 @@ { "version": "1.0.0-*", + "buildOptions": { + "copyToOutput": { + "include": [ + "../../artifacts/*/stage2/sdk/*/.version" + ], + "mappings": { + ".version": "../../artifacts/*/stage2/sdk/*/.version" + } + } + }, "dependencies": { "Microsoft.NETCore.App": { "type": "platform", diff --git a/test/dotnet-publish3.Tests/GivenDotnetPublish3PublishesProjects.cs b/test/dotnet-publish3.Tests/GivenDotnetPublish3PublishesProjects.cs index 6d88fed0a..55e15c862 100644 --- a/test/dotnet-publish3.Tests/GivenDotnetPublish3PublishesProjects.cs +++ b/test/dotnet-publish3.Tests/GivenDotnetPublish3PublishesProjects.cs @@ -53,7 +53,7 @@ namespace Microsoft.DotNet.Cli.Publish3.Tests .CreateTestInstance(testAppName); var testProjectDirectory = testInstance.TestRoot; - var rid = RuntimeEnvironment.GetRuntimeIdentifier(); + var rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier(); new Publish3Command() .WithFramework("netcoreapp1.0") diff --git a/test/dotnet-publish3.Tests/project.json b/test/dotnet-publish3.Tests/project.json index 3ee83c3ca..4938f6a74 100644 --- a/test/dotnet-publish3.Tests/project.json +++ b/test/dotnet-publish3.Tests/project.json @@ -1,5 +1,15 @@ { "version": "1.0.0-*", + "buildOptions": { + "copyToOutput": { + "include": [ + "../../artifacts/*/stage2/sdk/*/.version" + ], + "mappings": { + ".version": "../../artifacts/*/stage2/sdk/*/.version" + } + } + }, "dependencies": { "Microsoft.NETCore.App": { "type": "platform", diff --git a/test/dotnet-run.UnitTests/project.json b/test/dotnet-run.UnitTests/project.json index 549a6ce2a..126e1d368 100644 --- a/test/dotnet-run.UnitTests/project.json +++ b/test/dotnet-run.UnitTests/project.json @@ -1,5 +1,15 @@ { "version": "1.0.0-*", + "buildOptions": { + "copyToOutput": { + "include": [ + "../../artifacts/*/stage2/sdk/*/.version" + ], + "mappings": { + ".version": "../../artifacts/*/stage2/sdk/*/.version" + } + } + }, "dependencies": { "Microsoft.NETCore.App": { "type": "platform", diff --git a/test/dotnet.Tests/PackagedCommandTests.cs b/test/dotnet.Tests/PackagedCommandTests.cs index 4670ee746..2d0a07722 100644 --- a/test/dotnet.Tests/PackagedCommandTests.cs +++ b/test/dotnet.Tests/PackagedCommandTests.cs @@ -22,7 +22,7 @@ namespace Microsoft.DotNet.Tests { get { - var rid = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier(); + var rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier(); var projectOutputPath = $"AppWithDirectDepDesktopAndPortable\\bin\\Debug\\net451\\{rid}\\dotnet-desktop-and-portable.exe"; return new[] { @@ -36,7 +36,7 @@ namespace Microsoft.DotNet.Tests { get { - var rid = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier(); + var rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier(); var projectOutputPath = $"LibraryWithDirectDependencyDesktopAndPortable\\bin\\Debug\\net451\\dotnet-desktop-and-portable.exe"; return new[] {