diff --git a/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/AddRidToRuntimeJson.cs b/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/AddRidToRuntimeJson.cs deleted file mode 100644 index 5842d0d82..000000000 --- a/src/SourceBuild/content/eng/tools/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat/AddRidToRuntimeJson.cs +++ /dev/null @@ -1,94 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.IO; -using System.Text; -using Microsoft.Build.Framework; -using Microsoft.Build.Utilities; -using NuGet.Packaging; -using NuGet.Packaging.Core; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System.Collections.Generic; -using System.Linq; -using NuGet.Versioning; - -namespace Microsoft.DotNet.Build.Tasks -{ - public class AddRidToRuntimeJson:Task - { - /// - /// [OS name].[version]-[architecture] - /// - [Required] - public string Rid { get; set; } - - [Required] - public string RuntimeJson { get; set; } - - private string runtimesIdentifier = "runtimes"; - - public override bool Execute() - { - string[] ridParts = Rid.Split('-'); - string osNameAndVersion = ridParts[0]; - string[] osParts = osNameAndVersion.Split(new char[] { '.' }, 2); - - if (ridParts.Length < 1 || osParts.Length < 2) - { - throw new System.InvalidOperationException($"Unknown rid format {Rid}."); - } - - // Acquire Rid parts: - // osName - // version - // arch - string arch = ridParts[1]; - string osName = osParts[0]; - string version = osParts[1]; - - JObject projectRoot = ReadProject(RuntimeJson); - - if (projectRoot.SelectToken($"{runtimesIdentifier}.{osName}") == null) - { - AddRidToRuntimeGraph(projectRoot, osName, "linux"); - AddRidToRuntimeGraph(projectRoot, $"{osName}-{arch}", osName, $"linux-{arch}"); - } - if(projectRoot.SelectToken($"{runtimesIdentifier}.{osName}.{version}") == null) - { - AddRidToRuntimeGraph(projectRoot, $"{osName}.{version}", osName); - AddRidToRuntimeGraph(projectRoot, $"{osName}.{version}-{arch}", $"{osName}.{version}", $"{osName}-{arch}"); - } - - WriteProject(projectRoot, RuntimeJson); - return true; - } - - private void AddRidToRuntimeGraph(JObject projectRoot, string name, params string[] imports) - { - projectRoot[runtimesIdentifier][name] = new JObject(new JProperty("#import", new JArray(imports))); - } - - private static JObject ReadProject(string projectJsonPath) - { - using (TextReader projectFileReader = File.OpenText(projectJsonPath)) - { - var projectJsonReader = new JsonTextReader(projectFileReader); - var serializer = new JsonSerializer(); - return serializer.Deserialize(projectJsonReader); - } - } - private static void WriteProject(JObject projectRoot, string projectJsonPath) - { - string projectJson = JsonConvert.SerializeObject(projectRoot, Formatting.Indented) + Environment.NewLine; - - if (!File.Exists(projectJsonPath) || !projectJson.Equals(File.ReadAllText(projectJsonPath))) - { - Directory.CreateDirectory(Path.GetDirectoryName(projectJsonPath)); - File.WriteAllText(projectJsonPath, projectJson); - } - } - } -} diff --git a/src/SourceBuild/content/repo-projects/Directory.Build.targets b/src/SourceBuild/content/repo-projects/Directory.Build.targets index 8499e90dd..baaa8cf59 100644 --- a/src/SourceBuild/content/repo-projects/Directory.Build.targets +++ b/src/SourceBuild/content/repo-projects/Directory.Build.targets @@ -543,8 +543,8 @@ - - + + diff --git a/src/SourceBuild/content/repo-projects/runtime.proj b/src/SourceBuild/content/repo-projects/runtime.proj index e9146e0a3..f68566967 100644 --- a/src/SourceBuild/content/repo-projects/runtime.proj +++ b/src/SourceBuild/content/repo-projects/runtime.proj @@ -16,7 +16,7 @@ $(NETCoreSdkRuntimeIdentifier.Substring(0, $(_platformIndex))) <_platformIndex>$(NETCoreSdkPortableRuntimeIdentifier.LastIndexOf('-')) - $(NETCoreSdkPortableRuntimeIdentifier.Substring(0, $(_platformIndex))) + $(NETCoreSdkPortableRuntimeIdentifier.Substring(0, $(_platformIndex)))-$(Platform) false true @@ -54,8 +54,6 @@ - - @@ -63,17 +61,5 @@ - - - $(ProjectDirectory)pkg/Microsoft.NETCore.Platforms/runtime.json - - - - - - diff --git a/src/redist/targets/GenerateBundledVersions.targets b/src/redist/targets/GenerateBundledVersions.targets index 3332b4200..06871eb53 100644 --- a/src/redist/targets/GenerateBundledVersions.targets +++ b/src/redist/targets/GenerateBundledVersions.targets @@ -1195,9 +1195,13 @@ Copyright (c) .NET Foundation. All rights reserved. DestinationFiles="$(SdkOutputDirectory)RuntimeIdentifierGraph.json" SkipUnchangedFiles="true"/> + +