Merge pull request #13132 from EgorBo/extend-product-commit-txt
Save runtime commit to productCommit-rid.txt
This commit is contained in:
commit
d354b6a6e3
3 changed files with 68 additions and 1 deletions
55
src/core-sdk-tasks/GetDependencyInfo.cs
Normal file
55
src/core-sdk-tasks/GetDependencyInfo.cs
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
// 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.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 VersionDetailsXmlFile { 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
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.LogWarning($"GetComponentCommit failed for VersionDetailsXmlFile={VersionDetailsXmlFile}, DependencyName={DependencyName}: {ex}");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -39,5 +39,6 @@
|
||||||
<UsingTask TaskName="GetLinuxNativeInstallerDependencyVersions" AssemblyFile="$(CoreSdkTaskDll)"/>
|
<UsingTask TaskName="GetLinuxNativeInstallerDependencyVersions" AssemblyFile="$(CoreSdkTaskDll)"/>
|
||||||
<UsingTask TaskName="CollatePackageDownloads" AssemblyFile="$(CoreSdkTaskDll)"/>
|
<UsingTask TaskName="CollatePackageDownloads" AssemblyFile="$(CoreSdkTaskDll)"/>
|
||||||
<UsingTask TaskName="GenerateSdkRuntimeIdentifierChain" AssemblyFile="$(CoreSdkTaskDll)"/>
|
<UsingTask TaskName="GenerateSdkRuntimeIdentifierChain" AssemblyFile="$(CoreSdkTaskDll)"/>
|
||||||
|
<UsingTask TaskName="GetDependencyInfo" AssemblyFile="$(CoreSdkTaskDll)"/>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -16,9 +16,20 @@
|
||||||
Overwrite="true"
|
Overwrite="true"
|
||||||
Encoding="ASCII" />
|
Encoding="ASCII" />
|
||||||
|
|
||||||
|
<GetDependencyInfo
|
||||||
|
VersionDetailsXmlFile="$(RepoRoot)eng/Version.Details.xml"
|
||||||
|
DependencyName="Microsoft.NETCore.App.Ref">
|
||||||
|
<Output TaskParameter="DependencyVersion" PropertyName="DepRuntimeVersion" />
|
||||||
|
<Output TaskParameter="DependencyCommit" PropertyName="DepRuntimeCommit" />
|
||||||
|
</GetDependencyInfo>
|
||||||
|
|
||||||
|
<!-- Format for productCommits-%rid%.txt:
|
||||||
|
installer:%commit%, %version
|
||||||
|
runtime:%commit%, $version
|
||||||
|
-->
|
||||||
<WriteLinesToFile
|
<WriteLinesToFile
|
||||||
File="$(ArtifactsShippingPackagesDir)productCommit-$(Rid).txt"
|
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"
|
Overwrite="true"
|
||||||
Encoding="ASCII"/>
|
Encoding="ASCII"/>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue