Moving the InferLegacyRestoreRuntime method to Test.Utilities, since it is needed only by tests.

This commit is contained in:
Livar Cunha 2016-10-10 09:52:39 -07:00
parent 09d811fdbd
commit c2bce2e2cc
15 changed files with 46 additions and 45 deletions

View file

@ -3,7 +3,6 @@
using System.Collections.Generic;
using Microsoft.DotNet.InternalAbstractions;
using Microsoft.DotNet.PlatformAbstractions;
namespace Microsoft.DotNet.Cli.Utils
{
@ -32,23 +31,5 @@ namespace Microsoft.DotNet.Cli.Utils
return RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers(fallbackIdentifiers);
}
// Gets the identfier that is used for restore by default (this is different from the actual RID, but only on Windows)
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;
}
}
}
}

View file

@ -5,9 +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("dotnet-compile.UnitTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("dotnet-publish.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("dotnet.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("EndToEnd, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("Microsoft.DotNet.Tools.Tests.Utilities, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("dotnet-publish3.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]

View file

@ -5,7 +5,6 @@ using System;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.InternalAbstractions;
using Microsoft.DotNet.PlatformAbstractions;
using Microsoft.DotNet.Tools.Test.Utilities;
@ -197,7 +196,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd
TestProject = Path.Combine(TestDirectory, "project.json");
OutputDirectory = Path.Combine(TestDirectory, s_outputdirName);
Rid = DotnetRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
Rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
}
private static void SetupStaticTestProject()

View file

@ -1,7 +1,6 @@
{
"version": "1.0.0-*",
"buildOptions": {
"keyFile": "../../tools/Key.snk",
"emitEntryPoint": true
},
"dependencies": {

View file

@ -13,7 +13,7 @@ namespace StreamForwarderTests
{
public class StreamForwarderTests : TestBase
{
private static readonly string s_rid = DotnetRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
private static readonly string s_rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
public static void Main()
{

View file

@ -73,7 +73,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
if (!portable)
{
var runtime = string.IsNullOrEmpty(_runtime) ?
DotnetRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier() :
DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier() :
_runtime;
return Path.Combine(config, framework, runtime, PublishSubfolderName);
}

View file

@ -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;
}
}
}
}

View file

@ -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 = DotnetRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
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 = DotnetRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
var rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
var fixture = ScriptVariablesFixture.GetFixtureWithRids(rid);
fixture.PostCompileScriptVariables.Should().ContainKey("compile:RuntimeOutputDir");
fixture.PostCompileScriptVariables["compile:RuntimeOutputDir"].Should().Be(fixture.RuntimeOutputDir);

View file

@ -33,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",

View file

@ -3,7 +3,6 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.InternalAbstractions;
using Microsoft.DotNet.TestFramework;
using Microsoft.DotNet.Tools.Test.Utilities;
@ -57,7 +56,7 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
{
var runnable = forceRunnable ||
string.IsNullOrEmpty(runtime) ||
(DotnetRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier().Contains(runtime));
(DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier().Contains(runtime));
var testInstance = GetTestInstance()
.WithLockFiles();

View file

@ -5,7 +5,6 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.InternalAbstractions;
using Microsoft.DotNet.TestFramework;
using Microsoft.DotNet.Tools.Test.Utilities;
@ -59,11 +58,11 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
{
new object[] { "1", "", "", "", "" },
new object[] { "2", "netcoreapp1.0", "", "", "" },
new object[] { "3", "", DotnetRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier(), "", "" },
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", DotnetRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier(), "Debug", "some/dir" },
new object[] { "7", "netcoreapp1.0", DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier(), "Debug", "some/dir" },
};
}
}
@ -225,7 +224,7 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
publishCommand = new PublishCommand(
lesserTestProject,
"netcoreapp1.0",
DotnetRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier());
DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier());
publishCommand.Execute().Should().Pass();
publishCommand.GetOutputDirectory().Should().HaveFile("TestLibraryLesser.dll");

View file

@ -1,7 +1,6 @@
{
"version": "1.0.0-*",
"buildOptions": {
"keyFile": "../../tools/Key.snk",
"copyToOutput": {
"include": [
"../../artifacts/*/stage2/sdk/*/.version"
@ -23,9 +22,6 @@
"Microsoft.DotNet.Tools.Tests.Utilities": {
"target": "project"
},
"Microsoft.DotNet.Cli.Utils": {
"target": "project"
},
"xunit": "2.2.0-beta3-build3330",
"xunit.netcore.extensions": "1.0.0-prerelease-00206",
"dotnet-test-xunit": "1.0.0-rc2-350904-49",

View file

@ -53,7 +53,7 @@ namespace Microsoft.DotNet.Cli.Publish3.Tests
.CreateTestInstance(testAppName);
var testProjectDirectory = testInstance.TestRoot;
var rid = DotnetRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
var rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
new Publish3Command()
.WithFramework("netcoreapp1.0")

View file

@ -1,7 +1,6 @@
{
"version": "1.0.0-*",
"buildOptions": {
"keyFile": "../../tools/Key.snk",
"copyToOutput": {
"include": [
"../../artifacts/*/stage2/sdk/*/.version"

View file

@ -22,7 +22,7 @@ namespace Microsoft.DotNet.Tests
{
get
{
var rid = DotnetRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
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 = DotnetRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
var rid = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
var projectOutputPath = $"LibraryWithDirectDependencyDesktopAndPortable\\bin\\Debug\\net451\\dotnet-desktop-and-portable.exe";
return new[]
{