Generate NETCoreSdkRuntimeIdentifierChain.txt in SDK folder

This commit is contained in:
Daniel Plaisted 2020-11-20 00:42:41 -08:00
parent 003b1d1d5c
commit 096e69de3a
4 changed files with 42 additions and 2 deletions

View file

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using NuGet.RuntimeModel;
namespace Microsoft.DotNet.Cli.Build
{
public class GenerateSdkRuntimeIdentifierChain : Task
{
[Required]
public string RuntimeIdentifier { get; set; }
[Required]
public string RuntimeIdentifierGraphPath { get; set; }
[Required]
public string RuntimeIdentifierChainOutputPath { get; set; }
public override bool Execute()
{
var runtimeIdentifierGraph = JsonRuntimeFormat.ReadRuntimeGraph(RuntimeIdentifierGraphPath);
var chainContents = string.Join("\n", runtimeIdentifierGraph.ExpandRuntime(RuntimeIdentifier));
File.WriteAllText(RuntimeIdentifierChainOutputPath, chainContents);
return true;
}
}
}

View file

@ -11,7 +11,8 @@
<PackageReference Include="Microsoft.Build" Version="15.7.179" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.7.179" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="NuGet.Versioning" Version="4.3.0" />
<PackageReference Include="NuGet.Versioning" Version="5.8.0" />
<PackageReference Include="NuGet.Packaging" Version="5.8.0" />
<PackageReference Include="System.Reflection.Metadata" Version="1.4.2" />
<PackageReference Include="WindowsAzure.Storage" Version="8.4.0" Condition="'$(DotNetBuildFromSource)' != 'true'" />
</ItemGroup>

View file

@ -39,5 +39,6 @@
<UsingTask TaskName="GetRuntimePackRids" AssemblyFile="$(CoreSdkTaskDll)"/>
<UsingTask TaskName="GenerateMSBuildExtensionsSWR" AssemblyFile="$(CoreSdkTaskDll)"/>
<UsingTask TaskName="GetLinuxNativeInstallerDependencyVersions" AssemblyFile="$(CoreSdkTaskDll)"/>
<UsingTask TaskName="GenerateSdkRuntimeIdentifierChain" AssemblyFile="$(CoreSdkTaskDll)"/>
</Project>

View file

@ -520,7 +520,12 @@ Copyright (c) .NET Foundation. All rights reserved.
<Copy SourceFiles="$(NuGetPackageRoot)/microsoft.netcore.platforms/$(_NETCorePlatformsPackageVersion)/runtime.json"
DestinationFiles="$(SdkOutputDirectory)RuntimeIdentifierGraph.json"
SkipUnchangedFiles="true"/>
SkipUnchangedFiles="true"/>
<GenerateSdkRuntimeIdentifierChain
RuntimeIdentifier="$(PortableProduktMonikerRid)"
RuntimeIdentifierGraphPath="$(SdkOutputDirectory)RuntimeIdentifierGraph.json"
RuntimeIdentifierChainOutputPath="$(SdkOutputDirectory)NETCoreSdkRuntimeIdentifierChain.txt"/>
</Target>
</Project>