From 2dea6cd6be3127d514e7ebf788c8af959b6b6cf5 Mon Sep 17 00:00:00 2001
From: Doug Bunting <6431421+dougbu@users.noreply.github.com>
Date: Wed, 9 Nov 2022 15:24:29 -0800
Subject: [PATCH] Use Arcade's `DownloadFile` in Windows hosting bundle - was
 still trying to use our version

---
 .../WindowsHostingBundle/Product.targets      | 64 +++++++++++++------
 1 file changed, 44 insertions(+), 20 deletions(-)

diff --git a/src/Installers/Windows/WindowsHostingBundle/Product.targets b/src/Installers/Windows/WindowsHostingBundle/Product.targets
index dab41417731..fcf92fa1a10 100644
--- a/src/Installers/Windows/WindowsHostingBundle/Product.targets
+++ b/src/Installers/Windows/WindowsHostingBundle/Product.targets
@@ -26,33 +26,57 @@
   </ItemGroup>
 
   <Target Name="FetchDependencies" BeforeTargets="Restore;CollectPackageReferences">
+    <!-- Use the BrowserDebugHost as a sentinel for the nonshipping version for NETCoreApp. -->
     <PropertyGroup>
-      <DotNetAssetRootUrl Condition=" '$(DotNetAssetRootUrl)' == '' ">https://dotnetcli.azureedge.net/dotnet/</DotNetAssetRootUrl>
-      <DotNetAssetRootUrl Condition=" ! $(DotNetAssetRootUrl.EndsWith('/'))">$(DotNetAssetRootUrl)/</DotNetAssetRootUrl>
-      <DotNetPrivateAssetRootUrl Condition=" '$(DotNetPrivateAssetRootUrl)' == '' ">https://dotnetclimsrc.azureedge.net/dotnet/</DotNetPrivateAssetRootUrl>
-      <DotNetPrivateAssetRootUrl Condition=" ! $(DotNetPrivateAssetRootUrl.EndsWith('/'))">$(DotNetPrivateAssetRootUrl)/</DotNetPrivateAssetRootUrl>
+      <x64RemoteAsset>Runtime/$(MicrosoftNETCoreBrowserDebugHostTransportVersion)/dotnet-runtime-$(MicrosoftNETCoreAppRuntimeVersion)-win-x64.exe</x64RemoteAsset>
+      <x64RemoteAssetFileName>dotnet-runtime-$(MicrosoftNETCoreAppRuntimeVersion)-win-x64.exe</x64RemoteAssetFileName>
+      <x86RemoteAsset>Runtime/$(MicrosoftNETCoreBrowserDebugHostTransportVersion)/dotnet-runtime-$(MicrosoftNETCoreAppRuntimeVersion)-win-x86.exe</x86RemoteAsset>
+      <x86RemoteAssetFileName>dotnet-runtime-$(MicrosoftNETCoreAppRuntimeVersion)-win-x86.exe</x86RemoteAssetFileName>
+      <arm64RemoteAsset>Runtime/$(MicrosoftNETCoreBrowserDebugHostTransportVersion)/dotnet-runtime-$(MicrosoftNETCoreAppRuntimeVersion)-win-arm64.exe</arm64RemoteAsset>
+      <arm64RemoteAssetFileName>dotnet-runtime-$(MicrosoftNETCoreAppRuntimeVersion)-win-arm64.exe</arm64RemoteAssetFileName>
     </PropertyGroup>
 
-    <!-- Use the BrowserDebugHost as a sentinel for the nonshipping version for NETCoreApp. -->
+    <MakeDir Directories="$(DepsPath)" />
+
+    <!-- Try various places to find the installers. It's either released (use official version),
+         public but un-released (use dotnetbuilds/public), or internal and unreleased (use dotnetbuilds/internal) -->
     <ItemGroup>
-      <RemoteAsset Include="Runtime/$(MicrosoftNETCoreBrowserDebugHostTransportVersion)/dotnet-runtime-$(MicrosoftNETCoreAppRuntimeVersion)-win-x64.exe">
-        <TargetFileName>dotnet-runtime-$(MicrosoftNETCoreAppRuntimeVersion)-win-x64.exe</TargetFileName>
-      </RemoteAsset>
-      <RemoteAsset Include="Runtime/$(MicrosoftNETCoreBrowserDebugHostTransportVersion)/dotnet-runtime-$(MicrosoftNETCoreAppRuntimeVersion)-win-x86.exe">
-        <TargetFileName>dotnet-runtime-$(MicrosoftNETCoreAppRuntimeVersion)-win-x86.exe</TargetFileName>
-      </RemoteAsset>
-      <RemoteAsset Include="Runtime/$(MicrosoftNETCoreBrowserDebugHostTransportVersion)/dotnet-runtime-$(MicrosoftNETCoreAppRuntimeVersion)-win-arm64.exe">
-        <TargetFileName>dotnet-runtime-$(MicrosoftNETCoreAppRuntimeVersion)-win-arm64.exe</TargetFileName>
-      </RemoteAsset>
+      <UrisToDownload Include="https://dotnetcli.azureedge.net/dotnet/Runtime/$(x64RemoteAsset)" />
+      <UrisToDownload Include="https://dotnetbuilds.azureedge.net/public/$(x64RemoteAsset)" />
+      <UrisToDownload Include="https://dotnetbuilds.azureedge.net/internal/$(x64RemoteAsset)">
+        <token>$(DotnetRuntimeSourceFeedKey)</token>
+      </UrisToDownload>
     </ItemGroup>
 
-    <MakeDir Directories="$(DepsPath)" />
+    <DownloadFile Condition=" ! Exists('$(DepsPath)$(x64RemoteAssetFileName)') "
+                  Uris="@(UrisToDownload)"
+                  DestinationPath="$(DepsPath)$(x64RemoteAssetFileName)" />
+
+    <ItemGroup>
+      <UrisToDownload Remove="@(UrisToDownload)" />
+      <UrisToDownload Include="https://dotnetcli.azureedge.net/dotnet/Runtime/$(x86RemoteAsset)" />
+      <UrisToDownload Include="https://dotnetbuilds.azureedge.net/public/$(x86RemoteAsset)" />
+      <UrisToDownload Include="https://dotnetbuilds.azureedge.net/internal/$(x86RemoteAsset)">
+        <token>$(DotnetRuntimeSourceFeedKey)</token>
+      </UrisToDownload>
+    </ItemGroup>
+
+    <DownloadFile Condition=" ! Exists('$(DepsPath)$(x86RemoteAssetFileName)') "
+                  Uris="@(UrisToDownload)"
+                  DestinationPath="$(DepsPath)$(x86RemoteAssetFileName)" />
+
+    <ItemGroup>
+      <UrisToDownload Remove="@(UrisToDownload)" />
+      <UrisToDownload Include="https://dotnetcli.azureedge.net/dotnet/Runtime/$(arm64RemoteAsset)" />
+      <UrisToDownload Include="https://dotnetbuilds.azureedge.net/public/$(arm64RemoteAsset)" />
+      <UrisToDownload Include="https://dotnetbuilds.azureedge.net/internal/$(arm64RemoteAsset)">
+        <token>$(DotnetRuntimeSourceFeedKey)</token>
+      </UrisToDownload>
+    </ItemGroup>
 
-    <DownloadFile Condition=" ! Exists('$(DepsPath)%(RemoteAsset.TargetFileName)') "
-                  Uri="$(DotNetAssetRootUrl)%(RemoteAsset.Identity)"
-                  PrivateUri="$(DotNetPrivateAssetRootUrl)%(RemoteAsset.Identity)"
-                  PrivateUriSuffix="$(DotNetAssetRootAccessTokenSuffix)"
-                  DestinationPath="$(DepsPath)%(RemoteAsset.TargetFileName)" />
+    <DownloadFile Condition=" ! Exists('$(DepsPath)$(arm64RemoteAssetFileName)') "
+                  Uris="@(UrisToDownload)"
+                  DestinationPath="$(DepsPath)$(arm64RemoteAssetFileName)" />
   </Target>
 
   <Target Name="ExtractPropertiesFromDotNetMsi" DependsOnTargets="FetchDependencies" BeforeTargets="BeforeBuild">
-- 
GitLab