Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
e4d259c
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Feb 10, 2025
a36d553
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Feb 17, 2025
155acd6
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Feb 24, 2025
4a287c1
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Feb 25, 2025
5596b5f
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Mar 3, 2025
40a37f8
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Mar 10, 2025
e50b435
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Mar 17, 2025
532c487
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Mar 24, 2025
cfcdf25
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Mar 31, 2025
da502c8
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Apr 7, 2025
6380dc4
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Apr 14, 2025
898ba16
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Apr 17, 2025
14eec39
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Apr 21, 2025
bbfa125
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Apr 28, 2025
e4960e6
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] May 5, 2025
b3a8fd8
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] May 12, 2025
94c05e3
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] May 19, 2025
e303b3f
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] May 26, 2025
7cadbaf
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jun 2, 2025
7c59c07
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jun 9, 2025
fddb63a
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jun 16, 2025
769dd9e
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jun 23, 2025
5237cd4
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jun 30, 2025
e22aefc
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jul 7, 2025
02f41d5
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jul 14, 2025
d9776ee
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jul 21, 2025
8354426
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jul 28, 2025
a22640e
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Aug 4, 2025
d154d27
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Aug 11, 2025
7f1a327
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Aug 18, 2025
51ce49b
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Aug 25, 2025
9220bcd
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Sep 1, 2025
dc750e5
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Sep 8, 2025
c9b26b5
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Sep 15, 2025
a9679a5
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Sep 22, 2025
2a41ed7
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Sep 29, 2025
f83229f
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Oct 6, 2025
bc77c81
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Oct 13, 2025
31f5c9b
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Oct 27, 2025
885d4ac
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Nov 3, 2025
741a533
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Nov 10, 2025
08458b5
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Nov 10, 2025
cfa80bc
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Nov 17, 2025
5ce33d3
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Nov 24, 2025
ea19ece
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Dec 1, 2025
90fc182
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Dec 8, 2025
3dda6b9
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Dec 15, 2025
9242969
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Dec 22, 2025
9dbefd0
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Dec 29, 2025
f83219a
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Jan 12, 2026
3535342
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Jan 19, 2026
ddf32e7
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Jan 26, 2026
80e5c56
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Feb 2, 2026
293a88b
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Feb 9, 2026
b046f4e
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Feb 16, 2026
2b9fe3f
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Feb 23, 2026
9a2ae37
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Mar 2, 2026
7b2f1fa
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Mar 9, 2026
b3d6a8a
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Mar 16, 2026
5666fd6
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Mar 23, 2026
32a33aa
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Mar 30, 2026
773e577
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Apr 6, 2026
a3363b4
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Apr 13, 2026
c1a11e8
Fix demand for agent pool in pipeline configuration
mmitche Apr 21, 2026
3b9d7d1
Update agent demands in pipeline configuration
mmitche Apr 22, 2026
63a87bc
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Apr 27, 2026
1de750c
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] May 4, 2026
3b5ec25
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] May 11, 2026
1f7cc82
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] May 18, 2026
53a2b78
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] May 25, 2026
3cad918
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Jun 1, 2026
c152885
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Jun 8, 2026
954ce80
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Jun 15, 2026
11fad6c
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Jun 29, 2026
29b54b6
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Jul 6, 2026
0182867
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Jul 13, 2026
0879352
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Jul 20, 2026
b521e32
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Jul 27, 2026
d08bfb0
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Aug 3, 2026
5a4bce9
Update dependencies from https://github.com/dotnet/arcade build 20260…
dotnet-maestro[bot] Aug 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ stages:
# agent pool can't be read from a user-defined variable (Azure DevOps limitation)
pool:
name: NetCore-Public
demands: ImageOverride -equals windows.vs2022preview.amd64.Open
demands: ImageOverride -equals windows.vs2022.amd64.Open
# runAsPublic is used in expressions, which can't read from user-defined variables
runAsPublic: false

Expand Down
4 changes: 2 additions & 2 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Dependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="10.0.0-beta.24510.1">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="11.0.0-beta.26407.8">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>380002a14775d7f68f098c7e6b7d1c3638bd4c5d</Sha>
<Sha>212960245c74330fbfb71776563638061e35446c</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Arcade.Wpf.Sdk" Version="6.0.0-preview.5.21220.1">
<Uri>https://github.com/dotnet/wpf</Uri>
Expand Down
5 changes: 5 additions & 0 deletions eng/common/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# `eng/common`

Files under `eng/common` come from [Arcade](https://github.com/dotnet/arcade).
Edits in `eng/common` will be overwritten by automation unless the changes are made directly in the Arcade repository.
For more information, see the [Arcade documentation](https://github.com/dotnet/arcade/tree/main/Documentation).
2 changes: 1 addition & 1 deletion eng/common/CIBuild.cmd
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@echo off
powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0Build.ps1""" -restore -build -test -sign -pack -publish -ci %*"
powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0Build.ps1""" -restore -build -test -sign -pack -publish -ci %*"
154 changes: 154 additions & 0 deletions eng/common/Get-GitHubAppToken.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# Mints a short-lived GitHub App installation access token by signing a JWT
# with a private key stored in Azure Key Vault (RSA, RS256). The signed JWT is
# exchanged with the GitHub API for a token scoped to a single installation.
#
# Requirements:
# - A GitHub App whose private key has been uploaded into Key Vault as an RSA
# key (the PEM converted to a Key Vault *key*, NOT stored as a secret).
# - The caller (the federated Azure service connection used to run this script)
# must have the `Key Vault Crypto User` role (or at minimum the `Sign`
# action) on that key.
# - The App must be installed on the target organization/account
# (`InstallationOwner`) with the permissions/repositories it needs.
#
# Installation tokens (ghs_*) are exempt from the enterprise classic-PAT
# lifetime policy, which is why this replaces the long-lived PAT.

[CmdletBinding()]
param(
# Name of the Key Vault that holds the GitHub App's RSA signing key.
[Parameter(Mandatory = $true)]
[string] $KeyVaultName,

# Name of the RSA key inside the Key Vault (the App's private key).
[Parameter(Mandatory = $true)]
[string] $KeyName,

# The GitHub App's Client ID (the value to put in the `iss` JWT claim).
[Parameter(Mandatory = $true)]
[string] $AppClientId,

# Login of the organization or user account whose installation we should
# mint the token for (e.g. `dotnet`, `microsoft`).
[Parameter(Mandatory = $true)]
[string] $InstallationOwner,

# Optional Azure DevOps pipeline variable name to set with the installation
# token (marked as a secret). When not specified, the token is written to
# stdout instead.
[Parameter(Mandatory = $false)]
[string] $OutputVariableName
)

$ErrorActionPreference = 'Stop'
$PSNativeCommandUseErrorActionPreference = $true

. $PSScriptRoot\pipeline-logging-functions.ps1

function ConvertTo-Base64Url([byte[]] $bytes) {
return [Convert]::ToBase64String($bytes).TrimEnd('=').Replace('+', '-').Replace('/', '_')
}

# Build JWT header and payload. Use [ordered] hashtables so JSON
# serialization is deterministic.
$jwtHeader = [ordered]@{
alg = 'RS256'
typ = 'JWT'
}
$now = [System.DateTimeOffset]::UtcNow
$jwtPayload = [ordered]@{
iat = $now.AddMinutes(-1).ToUnixTimeSeconds()
exp = $now.AddMinutes(5).ToUnixTimeSeconds()
iss = $AppClientId
}

$headerEncoded = ConvertTo-Base64Url ([System.Text.Encoding]::UTF8.GetBytes(($jwtHeader | ConvertTo-Json -Compress)))
$payloadEncoded = ConvertTo-Base64Url ([System.Text.Encoding]::UTF8.GetBytes(($jwtPayload | ConvertTo-Json -Compress)))
$signingInput = "$headerEncoded.$payloadEncoded"

# Key Vault `sign` expects the *digest* (base64), not the raw bytes.
$sha256 = [System.Security.Cryptography.SHA256]::Create()
$digestBytes = $sha256.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($signingInput))
$digestBase64 = [Convert]::ToBase64String($digestBytes)

Write-Host "Signing JWT with key '$KeyName' in vault '$KeyVaultName'..."
$previousNativeCommandErrorPreference = $PSNativeCommandUseErrorActionPreference
try {
# Azure CLI can emit non-fatal Python warnings to stderr even when signing succeeds.
# Use the exit code to determine success for this invocation.
$PSNativeCommandUseErrorActionPreference = $false
$signatureBase64 = az keyvault key sign `
--vault-name $KeyVaultName `
--name $KeyName `
--algorithm RS256 `
--digest $digestBase64 `
--query signature `
--output tsv `
--only-show-errors
$signExitCode = $LASTEXITCODE
}
catch {
Write-PipelineTelemetryError -Category 'Build' -Message "Failed to sign the JWT via Key Vault (key '$KeyName', vault '$KeyVaultName'): $_. Verify the service connection identity has the 'Key Vault Crypto User' role (Sign action) on the key."
exit 1
}
finally {
$PSNativeCommandUseErrorActionPreference = $previousNativeCommandErrorPreference
}
if ($signExitCode -ne 0 -or [string]::IsNullOrWhiteSpace($signatureBase64)) {
Write-PipelineTelemetryError -Category 'Build' -Message "'az keyvault key sign' exited with code $signExitCode for key '$KeyName' in vault '$KeyVaultName'. Verify the service connection identity has the 'Key Vault Crypto User' role (Sign action) on the key."
exit 1
}
$signatureUrl = $signatureBase64.Trim().TrimEnd('=').Replace('+', '-').Replace('/', '_')
$jwt = "$signingInput.$signatureUrl"

$headers = @{
Authorization = "Bearer $jwt"
'X-GitHub-Api-Version' = '2022-11-28'
Accept = 'application/vnd.github+json'
'User-Agent' = 'dotnet-arcade-onelocbuild'
}

Write-Host "Looking up installation for '$InstallationOwner'..."
try {
$installations = @()
$page = 1
do {
$pageInstallations = @(Invoke-RestMethod `
-Uri "https://api.github.com/app/installations?per_page=100&page=$page" `
-Headers $headers `
-Method Get)
$installations += $pageInstallations
$page++
} while ($pageInstallations.Count -eq 100)
}
catch {
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."
exit 1
}
$installation = $installations | Where-Object { $_.account.login -ieq $InstallationOwner } | Select-Object -First 1
if (-not $installation) {
$found = ($installations | ForEach-Object { $_.account.login }) -join ', '
Write-PipelineTelemetryError -Category 'Build' -Message "No installation found for '$InstallationOwner'. App is installed on: $found"
exit 1
}

try {
$tokenResponse = Invoke-RestMethod `
-Uri "https://api.github.com/app/installations/$($installation.id)/access_tokens" `
-Headers $headers `
-Method Post `
-ContentType 'application/json'
}
catch {
Write-PipelineTelemetryError -Category 'Build' -Message "Failed to mint an installation access token for '$InstallationOwner' (installation $($installation.id)): $_"
exit 1
}

Write-Host "Got installation token for '$InstallationOwner' (expires $($tokenResponse.expires_at))."
if ($OutputVariableName) {
Write-Host "Setting pipeline variable '$OutputVariableName'."
Write-Host "##vso[task.setvariable variable=$OutputVariableName;issecret=true]$($tokenResponse.token)"
}
else {
Write-Host $tokenResponse.token -ForegroundColor Green
}
104 changes: 60 additions & 44 deletions eng/common/SetupNugetSources.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@
# See example call for this script below.
#
# - task: PowerShell@2
# displayName: Setup Private Feeds Credentials
# displayName: Setup internal Feeds Credentials
# condition: eq(variables['Agent.OS'], 'Windows_NT')
# inputs:
# filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.ps1
# arguments: -ConfigFile $(Build.SourcesDirectory)/NuGet.config -Password $Env:Token
# filePath: $(System.DefaultWorkingDirectory)/eng/common/SetupNugetSources.ps1
# arguments: -ConfigFile $(System.DefaultWorkingDirectory)/NuGet.config
# env:
# Token: $(dn-bot-dnceng-artifact-feeds-rw)
# Token: $(InternalFeedToken)
#
# Note: This logic is abstracted into enable-internal-sources.yml, which uses
# NuGetAuthenticate or a WIF-backed service connection. Prefer that template
# over calling this script directly.
#
# Note that the NuGetAuthenticate task should be called after SetupNugetSources.
# This ensures that:
Expand All @@ -25,40 +29,58 @@
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)][string]$ConfigFile,
$Password
# Keep the legacy name as an alias while callers migrate secrets to the Token environment variable.
[Alias("Password")]$Credential
)

$ErrorActionPreference = "Stop"
Set-StrictMode -Version 2.0
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$feedCredential = if ($env:Token) { $env:Token } else { $Credential }

# This script only consumes helper functions from tools.ps1 to configure NuGet feeds.
# Skip importing configure-toolset.ps1 so that repo-specific toolset setup (e.g. acquiring
# a bootstrap SDK) is not triggered as a side effect of feed configuration.
$disableConfigureToolsetImport = $true

. $PSScriptRoot\tools.ps1

# Adds or enables the package source with the given name
function AddOrEnablePackageSource($sources, $disabledPackageSources, $SourceName, $SourceEndPoint, $creds, $Username, $credential) {
if ($disabledPackageSources -eq $null -or -not (EnableInternalPackageSource -DisabledPackageSources $disabledPackageSources -Creds $creds -PackageSourceName $SourceName -Credential $credential)) {
AddPackageSource -Sources $sources -SourceName $SourceName -SourceEndPoint $SourceEndPoint -Creds $creds -Username $Username -credential $credential
}
}

# Add source entry to PackageSources
function AddPackageSource($sources, $SourceName, $SourceEndPoint, $creds, $Username, $pwd) {
function AddPackageSource($sources, $SourceName, $SourceEndPoint, $creds, $Username, $credential) {
$packageSource = $sources.SelectSingleNode("add[@key='$SourceName']")

if ($packageSource -eq $null)
{
Write-Host "Adding package source $SourceName"

$packageSource = $doc.CreateElement("add")
$packageSource.SetAttribute("key", $SourceName)
$packageSource.SetAttribute("value", $SourceEndPoint)
$sources.AppendChild($packageSource) | Out-Null
}
else {
Write-Host "Package source $SourceName already present."
Write-Host "Package source $SourceName already present and enabled."
}

AddCredential -Creds $creds -Source $SourceName -Username $Username -pwd $pwd
AddCredential -Creds $creds -Source $SourceName -Username $Username -credential $credential
}

# Add a credential node for the specified source
function AddCredential($creds, $source, $username, $pwd) {
function AddCredential($creds, $source, $username, $credential) {
# If no cred supplied, don't do anything.
if (!$pwd) {
if (!$credential) {
return;
}

Write-Host "Inserting credential for feed: " $source

# Looks for credential configuration for the given SourceName. Create it if none is found.
$sourceElement = $creds.SelectSingleNode($Source)
if ($sourceElement -eq $null)
Expand Down Expand Up @@ -88,27 +110,30 @@ function AddCredential($creds, $source, $username, $pwd) {
$sourceElement.AppendChild($passwordElement) | Out-Null
}

$passwordElement.SetAttribute("value", $pwd)
$passwordElement.SetAttribute("value", $credential)
}

function InsertMaestroPrivateFeedCredentials($Sources, $Creds, $Username, $pwd) {
$maestroPrivateSources = $Sources.SelectNodes("add[contains(@key,'darc-int')]")

Write-Host "Inserting credentials for $($maestroPrivateSources.Count) Maestro's private feeds."

ForEach ($PackageSource in $maestroPrivateSources) {
Write-Host "`tInserting credential for Maestro's feed:" $PackageSource.Key
AddCredential -Creds $creds -Source $PackageSource.Key -Username $Username -pwd $pwd
# Enable all darc-int package sources.
function EnableMaestroInternalPackageSources($DisabledPackageSources, $Creds, $Credential) {
$maestroInternalSources = $DisabledPackageSources.SelectNodes("add[contains(@key,'darc-int')]")
ForEach ($DisabledPackageSource in $maestroInternalSources) {
EnableInternalPackageSource -DisabledPackageSources $DisabledPackageSources -Creds $Creds -PackageSourceName $DisabledPackageSource.key -Credential $Credential
}
}

function EnablePrivatePackageSources($DisabledPackageSources) {
$maestroPrivateSources = $DisabledPackageSources.SelectNodes("add[contains(@key,'darc-int')]")
ForEach ($DisabledPackageSource in $maestroPrivateSources) {
Write-Host "`tEnsuring private source '$($DisabledPackageSource.key)' is enabled by deleting it from disabledPackageSource"
# Enables an internal package source by name, if found. Returns true if the package source was found and enabled, false otherwise.
function EnableInternalPackageSource($DisabledPackageSources, $Creds, $PackageSourceName, $Credential) {
$DisabledPackageSource = $DisabledPackageSources.SelectSingleNode("add[@key='$PackageSourceName']")
if ($DisabledPackageSource) {
Write-Host "Enabling internal source '$($DisabledPackageSource.key)'."

# Due to https://github.com/NuGet/Home/issues/10291, we must actually remove the disabled entries
$DisabledPackageSources.RemoveChild($DisabledPackageSource)

AddCredential -Creds $creds -Source $DisabledPackageSource.Key -Username $userName -credential $credential
return $true
}
return $false
}

if (!(Test-Path $ConfigFile -PathType Leaf)) {
Expand All @@ -121,15 +146,17 @@ $doc = New-Object System.Xml.XmlDocument
$filename = (Get-Item $ConfigFile).FullName
$doc.Load($filename)

# Get reference to <PackageSources> or create one if none exist already
# Get reference to <PackageSources> - fail if none exist
$sources = $doc.DocumentElement.SelectSingleNode("packageSources")
if ($sources -eq $null) {
$sources = $doc.CreateElement("packageSources")
$doc.DocumentElement.AppendChild($sources) | Out-Null
Write-PipelineTelemetryError -Category 'Build' -Message "Eng/common/SetupNugetSources.ps1 returned a non-zero exit code. NuGet config file must contain a packageSources section: $ConfigFile"
ExitWithExitCode 1
}

$creds = $null
if ($Password) {
$feedSuffix = "v3/index.json"
if ($feedCredential) {
$feedSuffix = "v2"
# Looks for a <PackageSourceCredentials> node. Create it if none is found.
$creds = $doc.DocumentElement.SelectSingleNode("packageSourceCredentials")
if ($creds -eq $null) {
Expand All @@ -138,33 +165,22 @@ if ($Password) {
}
}

$userName = "dn-bot"

# Check for disabledPackageSources; we'll enable any darc-int ones we find there
$disabledSources = $doc.DocumentElement.SelectSingleNode("disabledPackageSources")
if ($disabledSources -ne $null) {
Write-Host "Checking for any darc-int disabled package sources in the disabledPackageSources node"
EnablePrivatePackageSources -DisabledPackageSources $disabledSources
EnableMaestroInternalPackageSources -DisabledPackageSources $disabledSources -Creds $creds -Credential $feedCredential
}

$userName = "dn-bot"

# Insert credential nodes for Maestro's private feeds
InsertMaestroPrivateFeedCredentials -Sources $sources -Creds $creds -Username $userName -pwd $Password

# 3.1 uses a different feed url format so it's handled differently here
$dotnet31Source = $sources.SelectSingleNode("add[@key='dotnet3.1']")
if ($dotnet31Source -ne $null) {
AddPackageSource -Sources $sources -SourceName "dotnet3.1-internal" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal/nuget/v2" -Creds $creds -Username $userName -pwd $Password
AddPackageSource -Sources $sources -SourceName "dotnet3.1-internal-transport" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal-transport/nuget/v2" -Creds $creds -Username $userName -pwd $Password
}

$dotnetVersions = @('5','6','7','8','9')
$dotnetVersions = @('5','6','7','8','9','10')

foreach ($dotnetVersion in $dotnetVersions) {
$feedPrefix = "dotnet" + $dotnetVersion;
$dotnetSource = $sources.SelectSingleNode("add[@key='$feedPrefix']")
if ($dotnetSource -ne $null) {
AddPackageSource -Sources $sources -SourceName "$feedPrefix-internal" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/internal/_packaging/$feedPrefix-internal/nuget/v2" -Creds $creds -Username $userName -pwd $Password
AddPackageSource -Sources $sources -SourceName "$feedPrefix-internal-transport" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/internal/_packaging/$feedPrefix-internal-transport/nuget/v2" -Creds $creds -Username $userName -pwd $Password
AddOrEnablePackageSource -Sources $sources -DisabledPackageSources $disabledSources -SourceName "$feedPrefix-internal" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/internal/_packaging/$feedPrefix-internal/nuget/$feedSuffix" -Creds $creds -Username $userName -credential $feedCredential
AddOrEnablePackageSource -Sources $sources -DisabledPackageSources $disabledSources -SourceName "$feedPrefix-internal-transport" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/internal/_packaging/$feedPrefix-internal-transport/nuget/$feedSuffix" -Creds $creds -Username $userName -credential $feedCredential
}
}

Expand Down
Loading
Loading