Skip to content

Commit 6fe6a42

Browse files
[main] Source code updates from dotnet/arcade (#8667)
[main] Source code updates from dotnet/arcade
1 parent fe2ef94 commit 6fe6a42

10 files changed

Lines changed: 359 additions & 21 deletions

File tree

‎src/arcade/eng/Version.Details.props‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ This file should be imported by eng/Versions.props
66
<Project>
77
<PropertyGroup>
88
<!-- dotnet-arcade dependencies -->
9-
<MicrosoftDotNetArcadeSdkPackageVersion>11.0.0-beta.26418.5</MicrosoftDotNetArcadeSdkPackageVersion>
10-
<MicrosoftDotNetHelixSdkPackageVersion>11.0.0-beta.26418.5</MicrosoftDotNetHelixSdkPackageVersion>
9+
<MicrosoftDotNetArcadeSdkPackageVersion>11.0.0-beta.26424.2</MicrosoftDotNetArcadeSdkPackageVersion>
10+
<MicrosoftDotNetHelixSdkPackageVersion>11.0.0-beta.26424.2</MicrosoftDotNetHelixSdkPackageVersion>
1111
<!-- dotnet-arcade-services dependencies -->
1212
<MicrosoftDotNetDarcLibPackageVersion>1.1.0-beta.26413.1</MicrosoftDotNetDarcLibPackageVersion>
1313
<MicrosoftDotNetProductConstructionServiceClientPackageVersion>1.1.0-beta.26413.1</MicrosoftDotNetProductConstructionServiceClientPackageVersion>

‎src/arcade/eng/Version.Details.xml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Dependencies>
3-
<Source Uri="https://github.com/dotnet/dotnet" Mapping="arcade" Sha="7cdb217445905f3342bbb0266a4497b9a014389a" BarId="326717" />
3+
<Source Uri="https://github.com/dotnet/dotnet" Mapping="arcade" Sha="18aca855818ca5e09075637626229cd6d73011b9" BarId="328502" />
44
<ProductDependencies>
55
</ProductDependencies>
66
<ToolsetDependencies>
@@ -16,13 +16,13 @@
1616
<Uri>https://github.com/dotnet/templating</Uri>
1717
<Sha>43b5827697e501c442eb75ffff832cd4df2514fe</Sha>
1818
</Dependency>
19-
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="11.0.0-beta.26418.5">
19+
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="11.0.0-beta.26424.2">
2020
<Uri>https://github.com/dotnet/arcade</Uri>
21-
<Sha>16008eb13e491739070780951d879c494084952a</Sha>
21+
<Sha>5801fbf79d98359edda92efce57fd46af02ffff6</Sha>
2222
</Dependency>
23-
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="11.0.0-beta.26418.5">
23+
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="11.0.0-beta.26424.2">
2424
<Uri>https://github.com/dotnet/arcade</Uri>
25-
<Sha>16008eb13e491739070780951d879c494084952a</Sha>
25+
<Sha>5801fbf79d98359edda92efce57fd46af02ffff6</Sha>
2626
</Dependency>
2727
<Dependency Name="Microsoft.DotNet.ProductConstructionService.Client" Version="1.1.0-beta.26413.1">
2828
<Uri>https://github.com/dotnet/arcade-services</Uri>
@@ -175,4 +175,4 @@
175175
<Sha>f7d90799ce4ef09a0bb257852a57248d2a8fb8dd</Sha>
176176
</Dependency>
177177
</ToolsetDependencies>
178-
</Dependencies>
178+
</Dependencies>

‎src/arcade/eng/common/Get-GitHubAppToken.ps1‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,20 @@ $headers = @{
110110

111111
Write-Host "Looking up installation for '$InstallationOwner'..."
112112
try {
113-
$installations = @()
113+
$installations = [System.Collections.Generic.List[object]]::new()
114114
$page = 1
115115
do {
116-
# Assign the response before wrapping it in @(). PowerShell otherwise
117-
# preserves a top-level JSON array as one nested pipeline object.
118116
$pageResponse = Invoke-RestMethod `
119117
-Uri "https://api.github.com/app/installations?per_page=100&page=$page" `
120118
-Headers $headers `
121119
-Method Get
122-
$pageInstallations = @($pageResponse)
123-
$installations += $pageInstallations
120+
$pageInstallationCount = 0
121+
foreach ($installation in $pageResponse) {
122+
$installations.Add($installation)
123+
$pageInstallationCount++
124+
}
124125
$page++
125-
} while ($pageInstallations.Count -eq 100)
126+
} while ($pageInstallationCount -eq 100)
126127
}
127128
catch {
128129
Write-PipelineTelemetryError -Category 'Build' -Message "Failed to list GitHub App installations: $_. The signed JWT may be invalid or the App's Client ID ('$AppClientId') may be incorrect."

‎src/arcade/global.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "11.0.100-preview.6.26359.118",
3+
"version": "11.0.100-rc.1.26420.103",
44
"rollForward": "latestFeature",
55
"paths": [
66
".dotnet",
@@ -9,11 +9,11 @@
99
"errorMessage": "The required .NET SDK wasn't found. Please run ./eng/common/dotnet.cmd/sh to install it."
1010
},
1111
"tools": {
12-
"dotnet": "11.0.100-preview.6.26359.118"
12+
"dotnet": "11.0.100-rc.1.26420.103"
1313
},
1414
"msbuild-sdks": {
15-
"Microsoft.DotNet.Arcade.Sdk": "11.0.0-beta.26418.5",
16-
"Microsoft.DotNet.Helix.Sdk": "11.0.0-beta.26418.5",
15+
"Microsoft.DotNet.Arcade.Sdk": "11.0.0-beta.26424.2",
16+
"Microsoft.DotNet.Helix.Sdk": "11.0.0-beta.26424.2",
1717
"Microsoft.Build.NoTargets": "3.7.0"
1818
}
1919
}

‎src/arcade/src/Microsoft.DotNet.Build.Tasks.Feed/src/model/PublishingConstants.cs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,6 +2371,18 @@ public enum BuildQuality
23712371
symbolTargetType: SymbolPublishVisibility.Public,
23722372
flatten: false),
23732373

2374+
// 18.12
2375+
new TargetChannelConfig(
2376+
id: 10894,
2377+
isInternal: false,
2378+
publishingInfraVersion: PublishingInfraVersion.Latest,
2379+
akaMSChannelNames: [],
2380+
akaMSCreateLinkPatterns: DefaultAkaMSCreateLinkPatterns,
2381+
akaMSDoNotCreateLinkPatterns: DefaultAkaMSDoNotCreateLinkPatterns,
2382+
targetFeeds: DotNetToolsFeeds,
2383+
symbolTargetType: SymbolPublishVisibility.Public,
2384+
flatten: false),
2385+
23742386
// VS 18 - Latest
23752387
new TargetChannelConfig(
23762388
id: 10709,

‎src/arcade/src/Microsoft.DotNet.Helix/Client/CSharp/ApiFactory.cs‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
5+
using Azure.Core;
56

67
namespace Microsoft.DotNet.Helix.Client
78
{
@@ -20,6 +21,15 @@ public static IHelixApi GetAuthenticated(string accessToken)
2021
return new HelixApi(new HelixApiOptions(new HelixApiTokenCredential(accessToken)));
2122
}
2223

24+
/// <summary>
25+
/// Obtains an API client using an Entra credential for authenticated access to internal queues.
26+
/// The client requests the production Helix API scope and refreshes tokens based on their expiry.
27+
/// </summary>
28+
public static IHelixApi GetAuthenticatedWithEntra(TokenCredential credential)
29+
{
30+
return new HelixApi(new HelixApiOptions(ValidateEntraCredential(credential)));
31+
}
32+
2333
/// <summary>
2434
/// Obtains API client for unauthenticated access to external queues.
2535
/// The client will access production Helix instance.
@@ -46,6 +56,29 @@ public static IHelixApi GetAuthenticated(string baseUri, string accessToken)
4656
return new HelixApi(new HelixApiOptions(new Uri(baseUri), new HelixApiTokenCredential(accessToken)));
4757
}
4858

59+
/// <summary>
60+
/// Obtains an API client using an Entra credential for authenticated access to the provided Helix instance.
61+
/// Production and staging scopes are selected from the base URI.
62+
/// </summary>
63+
public static IHelixApi GetAuthenticatedWithEntra(string baseUri, TokenCredential credential)
64+
{
65+
return new HelixApi(new HelixApiOptions(new Uri(baseUri), ValidateEntraCredential(credential)));
66+
}
67+
68+
/// <summary>
69+
/// Obtains an API client using an Entra credential and explicit scope for a custom Helix instance.
70+
/// </summary>
71+
public static IHelixApi GetAuthenticatedWithEntra(
72+
string baseUri,
73+
TokenCredential credential,
74+
string scope)
75+
{
76+
return new HelixApi(new HelixApiOptions(
77+
new Uri(baseUri),
78+
ValidateEntraCredential(credential),
79+
new[] { scope }));
80+
}
81+
4982
/// <summary>
5083
/// Obtains API client for unauthenticated access to external queues.
5184
/// The client will access Helix instance at the provided URI.
@@ -58,5 +91,22 @@ public static IHelixApi GetAnonymous(string baseUri)
5891
{
5992
return new HelixApi(new HelixApiOptions(new Uri(baseUri)));
6093
}
94+
95+
private static TokenCredential ValidateEntraCredential(TokenCredential credential)
96+
{
97+
if (credential == null)
98+
{
99+
throw new ArgumentNullException(nameof(credential));
100+
}
101+
102+
if (credential is HelixApiTokenCredential)
103+
{
104+
throw new ArgumentException(
105+
"HelixApiTokenCredential represents a PAT. Use GetAuthenticated(...) for PAT authentication.",
106+
nameof(credential));
107+
}
108+
109+
return credential;
110+
}
61111
}
62112
}

‎src/arcade/src/Microsoft.DotNet.Helix/Client/CSharp/HelixApiOptions.cs‎

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,118 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using Azure.Core;
5+
using Azure.Core.Pipeline;
56
using System;
7+
using System.Collections.Generic;
8+
using System.Linq;
69

710
namespace Microsoft.DotNet.Helix.Client
811
{
12+
public enum HelixApiAuthenticationMode
13+
{
14+
Anonymous,
15+
PersonalAccessToken,
16+
EntraId,
17+
}
18+
919
partial class HelixApiOptions
1020
{
21+
public const string ProductionScope = "api://eb70c40b-c265-44f7-842e-1a568f035f33/.default";
22+
public const string StagingScope = "api://f45b17a4-149b-4f89-91bc-e6331af8d0e8/.default";
23+
1124
// See https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/core/Azure.Core/src/RetryOptions.cs for values this overrides
1225
public const int DefaultRetryDelaySeconds = 10;
1326
public const int DefaultMaxRetryCount = 5;
1427

28+
public HelixApiOptions(Uri baseUri, TokenCredential credentials, IEnumerable<string> scopes)
29+
{
30+
BaseUri = ValidateBaseUri(baseUri);
31+
Credentials = credentials ?? throw new ArgumentNullException(nameof(credentials));
32+
if (credentials is HelixApiTokenCredential)
33+
{
34+
throw new ArgumentException(
35+
"Explicit scopes are only supported for Entra credentials. " +
36+
"For PAT authentication, pass HelixApiTokenCredential without explicit scopes.",
37+
nameof(credentials));
38+
}
39+
40+
string[] tokenScopes = scopes?.ToArray() ?? throw new ArgumentNullException(nameof(scopes));
41+
if (tokenScopes.Length == 0 || tokenScopes.Any(string.IsNullOrWhiteSpace))
42+
{
43+
throw new ArgumentException("At least one non-empty token scope is required.", nameof(scopes));
44+
}
45+
TokenScopes = Array.AsReadOnly(tokenScopes);
46+
47+
InitializeOptions();
48+
}
49+
50+
public HelixApiAuthenticationMode AuthenticationMode { get; private set; }
51+
52+
public IReadOnlyList<string> TokenScopes { get; private set; } = Array.Empty<string>();
53+
1554
partial void InitializeOptions()
1655
{
17-
if (Credentials != null)
56+
if (Credentials == null)
1857
{
58+
AuthenticationMode = HelixApiAuthenticationMode.Anonymous;
59+
}
60+
else if (Credentials is HelixApiTokenCredential)
61+
{
62+
AuthenticationMode = HelixApiAuthenticationMode.PersonalAccessToken;
63+
TokenScopes = Array.Empty<string>();
1964
AddPolicy(new HelixApiTokenAuthenticationPolicy(Credentials), HttpPipelinePosition.PerCall);
2065
}
66+
else
67+
{
68+
AuthenticationMode = HelixApiAuthenticationMode.EntraId;
69+
if (TokenScopes.Count == 0)
70+
{
71+
TokenScopes = Array.AsReadOnly(new[] { GetDefaultScope(BaseUri) });
72+
}
73+
74+
AddPolicy(
75+
new BearerTokenAuthenticationPolicy(Credentials, TokenScopes.ToArray()),
76+
HttpPipelinePosition.PerRetry);
77+
}
2178

2279
// Users should not generally need to modify these but can do so after creating a HelixApi object if needed
2380
Retry.Delay = TimeSpan.FromSeconds(DefaultRetryDelaySeconds);
2481
Retry.MaxRetries = DefaultMaxRetryCount;
2582
}
83+
84+
private static string GetDefaultScope(Uri baseUri)
85+
{
86+
baseUri = ValidateBaseUri(baseUri);
87+
88+
if (baseUri.Host.Equals("helix.dot.net", StringComparison.OrdinalIgnoreCase))
89+
{
90+
return ProductionScope;
91+
}
92+
93+
if (baseUri.Host.Equals("helix.int-dot.net", StringComparison.OrdinalIgnoreCase))
94+
{
95+
return StagingScope;
96+
}
97+
98+
throw new ArgumentException(
99+
$"No default Entra scope is known for Helix API host '{baseUri.Host}'. " +
100+
"Use the HelixApiOptions constructor that accepts explicit scopes.",
101+
nameof(baseUri));
102+
}
103+
104+
private static Uri ValidateBaseUri(Uri baseUri)
105+
{
106+
if (baseUri == null)
107+
{
108+
throw new ArgumentNullException(nameof(baseUri));
109+
}
110+
111+
if (!baseUri.IsAbsoluteUri)
112+
{
113+
throw new ArgumentException("The Helix API base URI must be absolute.", nameof(baseUri));
114+
}
115+
116+
return baseUri;
117+
}
26118
}
27119
}

0 commit comments

Comments
 (0)