From 8fa51f49e8d27c342c78c85bdbc72f767fd538c4 Mon Sep 17 00:00:00 2001 From: EgorBo Date: Thu, 27 Jan 2022 19:21:52 +0300 Subject: [PATCH 1/4] Save dependent dotnet/runtime's commit and version to productCommit-rid.txt --- src/core-sdk-tasks/GetDependencyInfo.cs | 60 +++++++++++++++++++ src/redist/targets/BuildCoreSdkTasks.targets | 1 + .../targets/GenerateBundledVersions.targets | 13 +++- 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 src/core-sdk-tasks/GetDependencyInfo.cs diff --git a/src/core-sdk-tasks/GetDependencyInfo.cs b/src/core-sdk-tasks/GetDependencyInfo.cs new file mode 100644 index 000000000..5e4e7ce84 --- /dev/null +++ b/src/core-sdk-tasks/GetDependencyInfo.cs @@ -0,0 +1,60 @@ +// 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; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Xml.Linq; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +namespace Microsoft.DotNet.Cli.Build +{ + /// + /// Gets version and commit of a dependency by its name + /// from eng/Version.Details.xml + /// + public class GetDependencyInfo : Task + { + [Required] + public string DotnetInstallerCommit { get; set; } + + [Required] + public string DependencyName { get; set; } + + [Output] + public string DependencyVersion { get; set; } + + [Output] + public string DependencyCommit { get; set; } + + public override bool Execute() + { + try + { + using Stream file = new HttpClient().GetStreamAsync( + $"https://raw.githubusercontent.com/dotnet/installer/{DotnetInstallerCommit}/eng/Version.Details.xml") + .Result; + + XDocument document = XDocument.Load(file); + XElement dependency = document + .Element("Dependencies")? + .Element("ProductDependencies")? + .Elements("Dependency") + .FirstOrDefault(d => DependencyName.Equals(d.Attribute("Name")?.Value)); + + if (dependency != null) + { + DependencyVersion = dependency.Attribute("Version")?.Value; + DependencyCommit = dependency.Element("Sha")?.Value; + } + } + catch (Exception ex) + { + Log.LogWarning($"GetComponentCommit failed for DotnetInstallerCommit={DotnetInstallerCommit}, DependencyName={DependencyName}: {ex}"); + } + return true; + } + } +} diff --git a/src/redist/targets/BuildCoreSdkTasks.targets b/src/redist/targets/BuildCoreSdkTasks.targets index f89f2297f..e93fd0d06 100644 --- a/src/redist/targets/BuildCoreSdkTasks.targets +++ b/src/redist/targets/BuildCoreSdkTasks.targets @@ -39,5 +39,6 @@ + diff --git a/src/redist/targets/GenerateBundledVersions.targets b/src/redist/targets/GenerateBundledVersions.targets index 304e3e258..8ffdc6750 100644 --- a/src/redist/targets/GenerateBundledVersions.targets +++ b/src/redist/targets/GenerateBundledVersions.targets @@ -16,9 +16,20 @@ Overwrite="true" Encoding="ASCII" /> + + + + + + From 1dc073731d9bce7aa3c58462e4a3961bdc780421 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Thu, 27 Jan 2022 20:19:51 +0300 Subject: [PATCH 2/4] Update GetDependencyInfo.cs --- src/core-sdk-tasks/GetDependencyInfo.cs | 28 ++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/core-sdk-tasks/GetDependencyInfo.cs b/src/core-sdk-tasks/GetDependencyInfo.cs index 5e4e7ce84..dac61108d 100644 --- a/src/core-sdk-tasks/GetDependencyInfo.cs +++ b/src/core-sdk-tasks/GetDependencyInfo.cs @@ -33,21 +33,21 @@ namespace Microsoft.DotNet.Cli.Build { try { - using Stream file = new HttpClient().GetStreamAsync( - $"https://raw.githubusercontent.com/dotnet/installer/{DotnetInstallerCommit}/eng/Version.Details.xml") - .Result; - - XDocument document = XDocument.Load(file); - XElement dependency = document - .Element("Dependencies")? - .Element("ProductDependencies")? - .Elements("Dependency") - .FirstOrDefault(d => DependencyName.Equals(d.Attribute("Name")?.Value)); - - if (dependency != null) + string versionsXmlUrl = $"https://raw.githubusercontent.com/dotnet/installer/{DotnetInstallerCommit}/eng/Version.Details.xml"; + using (Stream file = new HttpClient().GetStreamAsync(versionsXmlUrl).Result) { - DependencyVersion = dependency.Attribute("Version")?.Value; - DependencyCommit = dependency.Element("Sha")?.Value; + XDocument document = XDocument.Load(file); + XElement dependency = document + .Element("Dependencies")? + .Element("ProductDependencies")? + .Elements("Dependency") + .FirstOrDefault(d => DependencyName.Equals(d.Attribute("Name")?.Value)); + + if (dependency != null) + { + DependencyVersion = dependency.Attribute("Version")?.Value; + DependencyCommit = dependency.Element("Sha")?.Value; + } } } catch (Exception ex) From 9469f5c7d1df93ebd8cc99ba7aae18b999a7c859 Mon Sep 17 00:00:00 2001 From: EgorBo Date: Sat, 5 Feb 2022 23:56:28 +0300 Subject: [PATCH 3/4] address feedback --- src/core-sdk-tasks/GetDependencyInfo.cs | 29 ++++++++----------- .../targets/GenerateBundledVersions.targets | 12 ++++++-- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/core-sdk-tasks/GetDependencyInfo.cs b/src/core-sdk-tasks/GetDependencyInfo.cs index dac61108d..909140113 100644 --- a/src/core-sdk-tasks/GetDependencyInfo.cs +++ b/src/core-sdk-tasks/GetDependencyInfo.cs @@ -4,7 +4,6 @@ using System; using System.IO; using System.Linq; -using System.Net.Http; using System.Xml.Linq; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; @@ -18,7 +17,7 @@ namespace Microsoft.DotNet.Cli.Build public class GetDependencyInfo : Task { [Required] - public string DotnetInstallerCommit { get; set; } + public string VersionDetailsXmlFile { get; set; } [Required] public string DependencyName { get; set; } @@ -33,26 +32,22 @@ namespace Microsoft.DotNet.Cli.Build { try { - string versionsXmlUrl = $"https://raw.githubusercontent.com/dotnet/installer/{DotnetInstallerCommit}/eng/Version.Details.xml"; - using (Stream file = new HttpClient().GetStreamAsync(versionsXmlUrl).Result) - { - XDocument document = XDocument.Load(file); - XElement dependency = document - .Element("Dependencies")? - .Element("ProductDependencies")? - .Elements("Dependency") - .FirstOrDefault(d => DependencyName.Equals(d.Attribute("Name")?.Value)); + XDocument document = XDocument.Load(VersionDetailsXmlFile); + XElement dependency = document + .Element("Dependencies")? + .Element("ProductDependencies")? + .Elements("Dependency") + .FirstOrDefault(d => DependencyName.Equals(d.Attribute("Name")?.Value)); - if (dependency != null) - { - DependencyVersion = dependency.Attribute("Version")?.Value; - DependencyCommit = dependency.Element("Sha")?.Value; - } + if (dependency != null) + { + DependencyVersion = dependency.Attribute("Version")?.Value; + DependencyCommit = dependency.Element("Sha")?.Value; } } catch (Exception ex) { - Log.LogWarning($"GetComponentCommit failed for DotnetInstallerCommit={DotnetInstallerCommit}, DependencyName={DependencyName}: {ex}"); + Log.LogWarning($"GetComponentCommit failed for VersionDetailsXmlFile={VersionDetailsXmlFile}, DependencyName={DependencyName}: {ex}"); } return true; } diff --git a/src/redist/targets/GenerateBundledVersions.targets b/src/redist/targets/GenerateBundledVersions.targets index 8ffdc6750..e419be4d4 100644 --- a/src/redist/targets/GenerateBundledVersions.targets +++ b/src/redist/targets/GenerateBundledVersions.targets @@ -16,19 +16,25 @@ Overwrite="true" Encoding="ASCII" /> + + - From 69f4dcf8498c47037cfc4d7fd29f185e6991c1ba Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Thu, 10 Feb 2022 17:51:44 +0300 Subject: [PATCH 4/4] Update GenerateBundledVersions.targets --- src/redist/targets/GenerateBundledVersions.targets | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/redist/targets/GenerateBundledVersions.targets b/src/redist/targets/GenerateBundledVersions.targets index e419be4d4..5563719e9 100644 --- a/src/redist/targets/GenerateBundledVersions.targets +++ b/src/redist/targets/GenerateBundledVersions.targets @@ -16,12 +16,6 @@ Overwrite="true" Encoding="ASCII" /> - - @@ -34,7 +28,7 @@ runtime:%commit%, $version -->