Merge pull request #9106 from dsplaisted/create-rid-chain

Add more RuntimeIdentifier information to .NET SDK
This commit is contained in:
Daniel Plaisted 2020-11-23 11:35:16 -08:00 committed by GitHub
commit 3a520ee2cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 48 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

@ -168,6 +168,11 @@
DefaultVersion="2.2.0"
LatestVersion="2.2.8"/>
</ItemGroup>
<PropertyGroup>
<PortableProductMonikerRid Condition="'$(PortableProductMonikerRid)' == ''">$(ProductMonikerRid)</PortableProductMonikerRid>
</PropertyGroup>
<PropertyGroup>
<BundledVersionsPropsContent>
@ -197,6 +202,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<BundledRuntimeIdentifierGraphFile>%24(MSBuildThisFileDirectory)RuntimeIdentifierGraph.json</BundledRuntimeIdentifierGraphFile>
<NETCoreSdkVersion>$(Version)</NETCoreSdkVersion>
<NETCoreSdkRuntimeIdentifier>$(ProductMonikerRid)</NETCoreSdkRuntimeIdentifier>
<NETCoreSdkPortableRuntimeIdentifier>$(PortableProductMonikerRid)</NETCoreSdkPortableRuntimeIdentifier>
<_NETCoreSdkIsPreview>$(_NETCoreSdkBeingBuiltIsPreview)</_NETCoreSdkIsPreview>
</PropertyGroup>
<ItemGroup>
@ -514,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="$(PortableProductMonikerRid)"
RuntimeIdentifierGraphPath="$(SdkOutputDirectory)RuntimeIdentifierGraph.json"
RuntimeIdentifierChainOutputPath="$(SdkOutputDirectory)NETCoreSdkRuntimeIdentifierChain.txt"/>
</Target>
</Project>