From c64b55a5907a8be4c9ae2bc7ff1c62a53045ef79 Mon Sep 17 00:00:00 2001
From: "dotnet-maestro[bot]" <dotnet-maestro[bot]@users.noreply.github.com>
Date: Thu, 12 Oct 2023 15:27:22 +0000
Subject: [PATCH] Update dependencies from https://github.com/dotnet/arcade
 build 20231011.8

Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.Build.Tasks.Installers , Microsoft.DotNet.Build.Tasks.Templating , Microsoft.DotNet.Helix.Sdk
 From Version 6.0.0-beta.23408.5 -> To Version 6.0.0-beta.23511.8
---
 NuGet.config                                | 12 +++---
 eng/Version.Details.xml                     | 16 ++++----
 eng/Versions.props                          |  4 +-
 eng/common/retain-build.ps1                 | 45 +++++++++++++++++++++
 eng/common/templates/steps/retain-build.yml | 28 +++++++++++++
 global.json                                 |  4 +-
 6 files changed, 91 insertions(+), 18 deletions(-)
 create mode 100644 eng/common/retain-build.ps1
 create mode 100644 eng/common/templates/steps/retain-build.yml

diff --git a/NuGet.config b/NuGet.config
index d37b12d22a3c..408f809f462b 100644
--- a/NuGet.config
+++ b/NuGet.config
@@ -5,11 +5,11 @@
     <!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
     <!--  Begin: Package sources from dotnet-runtime -->
     <add key="darc-int-dotnet-runtime-e0f0de8" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-runtime-e0f0de87/nuget/v3/index.json" />
+    <add key="darc-int-dotnet-runtime-e0f0de8-3" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-runtime-e0f0de87-3/nuget/v3/index.json" />
+    <add key="darc-int-dotnet-runtime-e0f0de8-2" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-runtime-e0f0de87-2/nuget/v3/index.json" />
+    <add key="darc-int-dotnet-runtime-e0f0de8-1" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-runtime-e0f0de87-1/nuget/v3/index.json" />
     <!--  End: Package sources from dotnet-runtime -->
     <!--  Begin: Package sources from dotnet-efcore -->
-    <add key="darc-int-dotnet-efcore-50a6896" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-efcore-50a6896c/nuget/v3/index.json" />
-    <add key="darc-int-dotnet-efcore-50a6896-2" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-efcore-50a6896c-2/nuget/v3/index.json" />
-    <add key="darc-int-dotnet-efcore-50a6896-1" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-efcore-50a6896c-1/nuget/v3/index.json" />
     <!--  End: Package sources from dotnet-efcore -->
     <!--End: Package sources managed by Dependency Flow automation. Do not edit the sources above.-->
     <add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
@@ -27,11 +27,11 @@
     <clear />
     <!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
     <!--  Begin: Package sources from dotnet-efcore -->
-    <add key="darc-int-dotnet-efcore-50a6896-1" value="true" />
-    <add key="darc-int-dotnet-efcore-50a6896-2" value="true" />
-    <add key="darc-int-dotnet-efcore-50a6896" value="true" />
     <!--  End: Package sources from dotnet-efcore -->
     <!--  Begin: Package sources from dotnet-runtime -->
+    <add key="darc-int-dotnet-runtime-e0f0de8-1" value="true" />
+    <add key="darc-int-dotnet-runtime-e0f0de8-2" value="true" />
+    <add key="darc-int-dotnet-runtime-e0f0de8-3" value="true" />
     <add key="darc-int-dotnet-runtime-e0f0de8" value="true" />
     <!--  End: Package sources from dotnet-runtime -->
     <!--End: Package sources managed by Dependency Flow automation. Do not edit the sources above.-->
diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml
index 86b6b375a58b..a94b8356c283 100644
--- a/eng/Version.Details.xml
+++ b/eng/Version.Details.xml
@@ -280,22 +280,22 @@
       <Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
       <Sha>0545d9fd7d80e0e8eaaff87aa0011ad5bc13fcc8</Sha>
     </Dependency>
-    <Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="6.0.0-beta.23408.5">
+    <Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="6.0.0-beta.23511.8">
       <Uri>https://github.com/dotnet/arcade</Uri>
-      <Sha>98fd22588fbb0f407faa6a74cb1aa79031306151</Sha>
+      <Sha>06ccd9430e2e3bd29a381a5b27e7976d11b0ed18</Sha>
       <SourceBuild RepoName="arcade" ManagedOnly="true" />
     </Dependency>
-    <Dependency Name="Microsoft.DotNet.Build.Tasks.Installers" Version="6.0.0-beta.23408.5">
+    <Dependency Name="Microsoft.DotNet.Build.Tasks.Installers" Version="6.0.0-beta.23511.8">
       <Uri>https://github.com/dotnet/arcade</Uri>
-      <Sha>98fd22588fbb0f407faa6a74cb1aa79031306151</Sha>
+      <Sha>06ccd9430e2e3bd29a381a5b27e7976d11b0ed18</Sha>
     </Dependency>
-    <Dependency Name="Microsoft.DotNet.Build.Tasks.Templating" Version="6.0.0-beta.23408.5">
+    <Dependency Name="Microsoft.DotNet.Build.Tasks.Templating" Version="6.0.0-beta.23511.8">
       <Uri>https://github.com/dotnet/arcade</Uri>
-      <Sha>98fd22588fbb0f407faa6a74cb1aa79031306151</Sha>
+      <Sha>06ccd9430e2e3bd29a381a5b27e7976d11b0ed18</Sha>
     </Dependency>
-    <Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="6.0.0-beta.23408.5">
+    <Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="6.0.0-beta.23511.8">
       <Uri>https://github.com/dotnet/arcade</Uri>
-      <Sha>98fd22588fbb0f407faa6a74cb1aa79031306151</Sha>
+      <Sha>06ccd9430e2e3bd29a381a5b27e7976d11b0ed18</Sha>
     </Dependency>
   </ToolsetDependencies>
 </Dependencies>
diff --git a/eng/Versions.props b/eng/Versions.props
index 2186c0e1d1eb..d20d7a658d46 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -131,8 +131,8 @@
     <MicrosoftEntityFrameworkCoreVersion>6.0.23</MicrosoftEntityFrameworkCoreVersion>
     <MicrosoftEntityFrameworkCoreDesignVersion>6.0.23</MicrosoftEntityFrameworkCoreDesignVersion>
     <!-- Packages from dotnet/arcade -->
-    <MicrosoftDotNetBuildTasksInstallersVersion>6.0.0-beta.23408.5</MicrosoftDotNetBuildTasksInstallersVersion>
-    <MicrosoftDotNetBuildTasksTemplatingVersion>6.0.0-beta.23408.5</MicrosoftDotNetBuildTasksTemplatingVersion>
+    <MicrosoftDotNetBuildTasksInstallersVersion>6.0.0-beta.23511.8</MicrosoftDotNetBuildTasksInstallersVersion>
+    <MicrosoftDotNetBuildTasksTemplatingVersion>6.0.0-beta.23511.8</MicrosoftDotNetBuildTasksTemplatingVersion>
   </PropertyGroup>
   <!--
 
diff --git a/eng/common/retain-build.ps1 b/eng/common/retain-build.ps1
new file mode 100644
index 000000000000..e7ba975adeb6
--- /dev/null
+++ b/eng/common/retain-build.ps1
@@ -0,0 +1,45 @@
+
+Param(
+[Parameter(Mandatory=$true)][int] $buildId,
+[Parameter(Mandatory=$true)][string] $azdoOrgUri, 
+[Parameter(Mandatory=$true)][string] $azdoProject,
+[Parameter(Mandatory=$true)][string] $token
+)
+
+$ErrorActionPreference = 'Stop'
+Set-StrictMode -Version 2.0
+
+function Get-AzDOHeaders(
+    [string] $token)
+{
+    $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":${token}"))
+    $headers = @{"Authorization"="Basic $base64AuthInfo"}
+    return $headers
+}
+
+function Update-BuildRetention(
+    [string] $azdoOrgUri,
+    [string] $azdoProject,
+    [int] $buildId,
+    [string] $token)
+{
+    $headers = Get-AzDOHeaders -token $token
+    $requestBody = "{
+        `"keepForever`": `"true`"
+    }"
+
+    $requestUri = "${azdoOrgUri}/${azdoProject}/_apis/build/builds/${buildId}?api-version=6.0"
+    write-Host "Attempting to retain build using the following URI: ${requestUri} ..."
+
+    try {
+        Invoke-RestMethod -Uri $requestUri -Method Patch -Body $requestBody -Header $headers -contentType "application/json"
+        Write-Host "Updated retention settings for build ${buildId}."
+    }
+    catch {
+        Write-Error "Failed to update retention settings for build: $_.Exception.Response.StatusDescription"
+        exit 1
+    }
+}
+
+Update-BuildRetention -azdoOrgUri $azdoOrgUri -azdoProject $azdoProject -buildId $buildId -token $token
+exit 0
diff --git a/eng/common/templates/steps/retain-build.yml b/eng/common/templates/steps/retain-build.yml
new file mode 100644
index 000000000000..83d97a26a01f
--- /dev/null
+++ b/eng/common/templates/steps/retain-build.yml
@@ -0,0 +1,28 @@
+parameters:
+  # Optional azure devops PAT with build execute permissions for the build's organization,
+  # only needed if the build that should be retained ran on a different organization than 
+  # the pipeline where this template is executing from
+  Token: ''
+  # Optional BuildId to retain, defaults to the current running build
+  BuildId: ''
+  # Azure devops Organization URI for the build in the https://dev.azure.com/<organization> format.
+  # Defaults to the organization the current pipeline is running on
+  AzdoOrgUri: '$(System.CollectionUri)'
+  # Azure devops project for the build. Defaults to the project the current pipeline is running on
+  AzdoProject: '$(System.TeamProject)'
+
+steps:
+  - task: powershell@2
+    inputs:
+      targetType: 'filePath'
+      filePath: eng/common/retain-build.ps1
+      pwsh: true
+      arguments: >
+        -AzdoOrgUri: ${{parameters.AzdoOrgUri}}
+        -AzdoProject ${{parameters.AzdoProject}}
+        -Token ${{coalesce(parameters.Token, '$env:SYSTEM_ACCESSTOKEN') }}
+        -BuildId ${{coalesce(parameters.BuildId, '$env:BUILD_ID')}}
+    displayName: Enable permanent build retention
+    env:
+      SYSTEM_ACCESSTOKEN: $(System.AccessToken)
+      BUILD_ID: $(Build.BuildId)
\ No newline at end of file
diff --git a/global.json b/global.json
index 83661f95122b..2b186f5181df 100644
--- a/global.json
+++ b/global.json
@@ -29,7 +29,7 @@
   },
   "msbuild-sdks": {
     "Yarn.MSBuild": "1.22.10",
-    "Microsoft.DotNet.Arcade.Sdk": "6.0.0-beta.23408.5",
-    "Microsoft.DotNet.Helix.Sdk": "6.0.0-beta.23408.5"
+    "Microsoft.DotNet.Arcade.Sdk": "6.0.0-beta.23511.8",
+    "Microsoft.DotNet.Helix.Sdk": "6.0.0-beta.23511.8"
   }
 }