Save dependent dotnet/runtime's commit and version to productCommit-rid.txt
This commit is contained in:
parent
542bf3308b
commit
8fa51f49e8
3 changed files with 73 additions and 1 deletions
60
src/core-sdk-tasks/GetDependencyInfo.cs
Normal file
60
src/core-sdk-tasks/GetDependencyInfo.cs
Normal file
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets version and commit of a dependency by its name
|
||||
/// from eng/Version.Details.xml
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -39,5 +39,6 @@
|
|||
<UsingTask TaskName="GetLinuxNativeInstallerDependencyVersions" AssemblyFile="$(CoreSdkTaskDll)"/>
|
||||
<UsingTask TaskName="CollatePackageDownloads" AssemblyFile="$(CoreSdkTaskDll)"/>
|
||||
<UsingTask TaskName="GenerateSdkRuntimeIdentifierChain" AssemblyFile="$(CoreSdkTaskDll)"/>
|
||||
<UsingTask TaskName="GetDependencyInfo" AssemblyFile="$(CoreSdkTaskDll)"/>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -16,9 +16,20 @@
|
|||
Overwrite="true"
|
||||
Encoding="ASCII" />
|
||||
|
||||
<GetDependencyInfo
|
||||
DotnetInstallerCommit="$(BUILD_SOURCEVERSION)"
|
||||
DependencyName="Microsoft.NETCore.App.Ref">
|
||||
<Output TaskParameter="DependencyVersion" PropertyName="DepRuntimeVersion" />
|
||||
<Output TaskParameter="DependencyCommit" PropertyName="DepRuntimeCommit" />
|
||||
</GetDependencyInfo>
|
||||
|
||||
<!-- Format for productCommit-%rid%.txt:
|
||||
installer:%commit%, %version
|
||||
runtime:%commit%, $version
|
||||
-->
|
||||
<WriteLinesToFile
|
||||
File="$(ArtifactsShippingPackagesDir)productCommit-$(Rid).txt"
|
||||
Lines="$(BUILD_SOURCEVERSION)%0A$(PackageVersion)"
|
||||
Lines="installer%3A$(BUILD_SOURCEVERSION)%2C%20$(PackageVersion)%0Aruntime%3A$(DepRuntimeCommit)%2C%20$(DepRuntimeVersion)%0A"
|
||||
Overwrite="true"
|
||||
Encoding="ASCII"/>
|
||||
|
||||
|
|
Loading…
Reference in a new issue