From 5ee269eef8bd02d066151deaa4d8c0fe6b6cbce4 Mon Sep 17 00:00:00 2001
Patch-Source: https://github.com/dotnet/installer/pull/14816
From: Antoine Martin <dev@ayakael.net>
Date: Tue, 15 Nov 2022 01:04:46 -0500
Subject: [PATCH 2/3] BundledVersions: update portable rid logic (backport
 dotnet#14647)

---
 .../tarball/content/repos/installer.proj         |  5 +++++
 src/redist/targets/GetRuntimeInformation.targets | 16 ++++++++++------
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/installer/src/redist/targets/GetRuntimeInformation.targets b/src/installer/src/redist/targets/GetRuntimeInformation.targets
index a99a7e9da..89f000119 100644
--- a/src/installer/src/redist/targets/GetRuntimeInformation.targets
+++ b/src/installer/src/redist/targets/GetRuntimeInformation.targets
@@ -9,10 +9,15 @@
       <HostOSName Condition=" '$(HostOSName)' == '' AND $([MSBuild]::IsOSPlatform('OSX')) ">osx</HostOSName>
       <HostOSName Condition=" '$(HostOSName)' == '' AND $([MSBuild]::IsOSPlatform('FREEBSD')) ">freebsd</HostOSName>
       <HostOSName Condition=" '$(HostOSName)' == '' AND '$(IsLinux)' == 'True' ">linux</HostOSName>
-      
+
+      <OSName Condition=" '$(OSName)' == '' AND $(Rid) != '' ">$(Rid.Substring(0, $(Rid.LastIndexOf('-'))))</OSName>
       <OSName Condition=" '$(OSName)' == '' ">$(HostOSName)</OSName>
 
-      <Rid Condition=" '$(Rid)' == '' ">$(OSName)-$(Architecture)</Rid>
+      <PortableOSName Condition=" '$(PortableOSName)' == '' ">$(OSName)</PortableOSName>
+
+      <Rid>$(OSName)-$(Architecture)</Rid>
+
+      <PortableRid>$(PortableOSName)-$(Architecture)</PortableRid>
     </PropertyGroup>
 
     <PropertyGroup>
@@ -23,10 +28,9 @@
     </PropertyGroup>
 
     <PropertyGroup>
-      <ProductMonikerRid Condition=" '$(Rid)' == 'ubuntu.16.04-x64' OR
-                                   '$(Rid)' == 'rhel.6-x64' OR
-                                   '$(Rid)' == 'linux-musl-x64' ">$(Rid)</ProductMonikerRid>
-      <ProductMonikerRid Condition=" '$(ProductMonikerRid)' == '' ">$(OSName)-$(Architecture)</ProductMonikerRid>
+      <ProductMonikerRid Condition=" '$(ProductMonikerRid)' == '' ">$(Rid)</ProductMonikerRid>
+
+      <PortableProductMonikerRid Condition=" '$(PortableProductMonikerRid)' == '' ">$(PortableRid)</PortableProductMonikerRid>
 
       <PortableProductMonikerRid Condition=" '$(PortableProductMonikerRid)' == '' ">$(HostOSName)-$(Architecture)</PortableProductMonikerRid>
 
-- 
2.38.2

