Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
68d84b5
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] May 20, 2025
e614edd
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] May 21, 2025
44e528c
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] May 22, 2025
9b56d34
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] May 31, 2025
d19e59c
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jun 3, 2025
7457ef3
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jun 5, 2025
832fffc
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jun 6, 2025
d1fea19
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jun 10, 2025
30b48d9
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jun 11, 2025
a4c8a76
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jun 12, 2025
aa1d152
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jun 13, 2025
3678f6a
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jun 14, 2025
7a89a02
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jun 17, 2025
b97979f
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jun 21, 2025
b967b96
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jun 24, 2025
008233e
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jun 25, 2025
1d01600
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jun 26, 2025
4a27711
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jun 27, 2025
1e2f02b
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jul 2, 2025
dc0ccb4
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jul 3, 2025
2bf9b7d
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jul 4, 2025
c3ac913
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jul 9, 2025
8fb0e26
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jul 18, 2025
04e9dfc
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jul 19, 2025
1a421df
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jul 24, 2025
d370549
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jul 25, 2025
ed2a6ff
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jul 26, 2025
03193e0
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Jul 30, 2025
922453d
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Aug 2, 2025
4858070
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Aug 9, 2025
5a73b02
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Aug 13, 2025
add44da
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Aug 14, 2025
425f3e7
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Aug 16, 2025
3775543
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Aug 17, 2025
58a2cf7
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Aug 19, 2025
9c64777
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Aug 20, 2025
55f1008
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Aug 21, 2025
10620b6
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Aug 23, 2025
b8ce6dd
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Aug 26, 2025
d88dccd
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Aug 27, 2025
1d35eec
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Aug 28, 2025
cccf22e
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Aug 29, 2025
8478de4
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Aug 31, 2025
ee8af20
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Sep 3, 2025
267e03c
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Sep 4, 2025
e6bd189
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Sep 5, 2025
6b22b98
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Sep 6, 2025
a87ab40
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Sep 8, 2025
e4842a1
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Sep 9, 2025
37f09f7
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Sep 10, 2025
6a37925
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Sep 12, 2025
443032e
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Sep 13, 2025
f0dfa75
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Sep 18, 2025
c873755
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Sep 19, 2025
1622f53
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Sep 20, 2025
e51502e
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Sep 27, 2025
9a0638a
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Sep 28, 2025
46e6121
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Sep 30, 2025
e6b01a4
Update dependencies from https://github.com/dotnet/arcade build 20250…
dotnet-maestro[bot] Oct 1, 2025
658a797
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Oct 2, 2025
7cf55ec
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Oct 3, 2025
710d262
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Oct 4, 2025
72ee5d7
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Oct 5, 2025
9935454
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Oct 7, 2025
67e888e
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Oct 8, 2025
1ace413
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Oct 9, 2025
5260d9c
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Oct 10, 2025
5045181
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Oct 21, 2025
0348383
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Oct 23, 2025
ae71c55
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Oct 25, 2025
4ede611
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Oct 28, 2025
08d15e9
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Oct 29, 2025
d9a69ac
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Oct 31, 2025
14e31f0
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Nov 1, 2025
7111fa8
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Nov 4, 2025
e8c0d55
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Nov 5, 2025
8b874af
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Nov 6, 2025
e40a505
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Nov 7, 2025
c65db1c
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Nov 8, 2025
f560da3
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Nov 10, 2025
622b337
Update dependencies from https://github.com/dotnet/arcade build 20251…
dotnet-maestro[bot] Nov 13, 2025
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
8 changes: 4 additions & 4 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<ProductDependencies>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="10.0.0-beta.25124.3">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="11.0.0-beta.25562.6">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>2117ebaa7336feccd2361eb01ce33c243249bce0</Sha>
<Sha>4bb60deca10193c27f5bdf0a6afc5878ef558455</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="10.0.0-beta.25124.3">
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="11.0.0-beta.25562.6">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>2117ebaa7336feccd2361eb01ce33c243249bce0</Sha>
<Sha>4bb60deca10193c27f5bdf0a6afc5878ef558455</Sha>
</Dependency>
</ToolsetDependencies>
</Dependencies>
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 %*"
77 changes: 41 additions & 36 deletions eng/common/SetupNugetSources.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
# 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 -Password $Env:Token
# env:
# Token: $(dn-bot-dnceng-artifact-feeds-rw)
#
Expand All @@ -34,19 +34,28 @@ Set-StrictMode -Version 2.0

. $PSScriptRoot\tools.ps1

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

# Add source entry to PackageSources
function AddPackageSource($sources, $SourceName, $SourceEndPoint, $creds, $Username, $pwd) {
$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
Expand All @@ -59,6 +68,8 @@ function AddCredential($creds, $source, $username, $pwd) {
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 @@ -91,24 +102,27 @@ function AddCredential($creds, $source, $username, $pwd) {
$passwordElement.SetAttribute("value", $pwd)
}

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) {
$maestroInternalSources = $DisabledPackageSources.SelectNodes("add[contains(@key,'darc-int')]")
ForEach ($DisabledPackageSource in $maestroInternalSources) {
EnableInternalPackageSource -DisabledPackageSources $DisabledPackageSources -Creds $Creds -PackageSourceName $DisabledPackageSource.key
}
}

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) {
$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 -pwd $Password
return $true
}
return $false
}

if (!(Test-Path $ConfigFile -PathType Leaf)) {
Expand All @@ -121,15 +135,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
$feedSuffix = "v3/index.json"
if ($Password) {
$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 +154,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
}

$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
EnableMaestroInternalPackageSources -DisabledPackageSources $disabledSources -Creds $creds
}

$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 -pwd $Password
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 -pwd $Password
}
}

Expand Down
179 changes: 104 additions & 75 deletions eng/common/SetupNugetSources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
# - task: Bash@3
# displayName: Setup Internal Feeds
# inputs:
# filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.sh
# arguments: $(Build.SourcesDirectory)/NuGet.config
# filePath: $(System.DefaultWorkingDirectory)/eng/common/SetupNugetSources.sh
# arguments: $(System.DefaultWorkingDirectory)/NuGet.config
# condition: ne(variables['Agent.OS'], 'Windows_NT')
# - task: NuGetAuthenticate@1
#
Expand Down Expand Up @@ -52,78 +52,124 @@ if [[ `uname -s` == "Darwin" ]]; then
TB=''
fi

# Ensure there is a <packageSources>...</packageSources> section.
grep -i "<packageSources>" $ConfigFile
if [ "$?" != "0" ]; then
echo "Adding <packageSources>...</packageSources> section."
ConfigNodeHeader="<configuration>"
PackageSourcesTemplate="${TB}<packageSources>${NL}${TB}</packageSources>"
# Enables an internal package source by name, if found. Returns 0 if found and enabled, 1 if not found.
EnableInternalPackageSource() {
local PackageSourceName="$1"

# Check if disabledPackageSources section exists
grep -i "<disabledPackageSources>" "$ConfigFile" > /dev/null
if [ "$?" != "0" ]; then
return 1 # No disabled sources section
fi

# Check if this source name is disabled
grep -i "<add key=\"$PackageSourceName\" value=\"true\"" "$ConfigFile" > /dev/null
if [ "$?" == "0" ]; then
echo "Enabling internal source '$PackageSourceName'."
# Remove the disabled entry (including any surrounding comments or whitespace on the same line)
sed -i.bak "/<add key=\"$PackageSourceName\" value=\"true\" \/>/d" "$ConfigFile"

# Add the source name to PackageSources for credential handling
PackageSources+=("$PackageSourceName")
return 0 # Found and enabled
fi

return 1 # Not found in disabled sources
}

# Add source entry to PackageSources
AddPackageSource() {
local SourceName="$1"
local SourceEndPoint="$2"

# Check if source already exists
grep -i "<add key=\"$SourceName\"" "$ConfigFile" > /dev/null
if [ "$?" == "0" ]; then
echo "Package source $SourceName already present and enabled."
PackageSources+=("$SourceName")
return
fi

echo "Adding package source $SourceName"
PackageSourcesNodeFooter="</packageSources>"
PackageSourceTemplate="${TB}<add key=\"$SourceName\" value=\"$SourceEndPoint\" />"

sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourceTemplate${NL}$PackageSourcesNodeFooter|" "$ConfigFile"
PackageSources+=("$SourceName")
}

# Adds or enables the package source with the given name
AddOrEnablePackageSource() {
local SourceName="$1"
local SourceEndPoint="$2"

# Try to enable if disabled, if not found then add new source
EnableInternalPackageSource "$SourceName"
if [ "$?" != "0" ]; then
AddPackageSource "$SourceName" "$SourceEndPoint"
fi
}

sed -i.bak "s|$ConfigNodeHeader|$ConfigNodeHeader${NL}$PackageSourcesTemplate|" $ConfigFile
fi
# Enable all darc-int package sources
EnableMaestroInternalPackageSources() {
# Check if disabledPackageSources section exists
grep -i "<disabledPackageSources>" "$ConfigFile" > /dev/null
if [ "$?" != "0" ]; then
return # No disabled sources section
fi

# Find all darc-int disabled sources
local DisabledDarcIntSources=()
DisabledDarcIntSources+=$(grep -oh '"darc-int-[^"]*" value="true"' "$ConfigFile" | tr -d '"')

for DisabledSourceName in ${DisabledDarcIntSources[@]} ; do
if [[ $DisabledSourceName == darc-int* ]]; then
EnableInternalPackageSource "$DisabledSourceName"
fi
done
}

# Ensure there is a <packageSourceCredentials>...</packageSourceCredentials> section.
grep -i "<packageSourceCredentials>" $ConfigFile
# Ensure there is a <packageSources>...</packageSources> section.
grep -i "<packageSources>" $ConfigFile
if [ "$?" != "0" ]; then
echo "Adding <packageSourceCredentials>...</packageSourceCredentials> section."

PackageSourcesNodeFooter="</packageSources>"
PackageSourceCredentialsTemplate="${TB}<packageSourceCredentials>${NL}${TB}</packageSourceCredentials>"

sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourcesNodeFooter${NL}$PackageSourceCredentialsTemplate|" $ConfigFile
Write-PipelineTelemetryError -Category 'Build' "Error: Eng/common/SetupNugetSources.sh returned a non-zero exit code. NuGet config file must contain a packageSources section: $ConfigFile"
ExitWithExitCode 1
fi

PackageSources=()

# Ensure dotnet3.1-internal and dotnet3.1-internal-transport are in the packageSources if the public dotnet3.1 feeds are present
grep -i "<add key=\"dotnet3.1\"" $ConfigFile
if [ "$?" == "0" ]; then
grep -i "<add key=\"dotnet3.1-internal\"" $ConfigFile
# Set feed suffix based on whether credentials are provided
FeedSuffix="v3/index.json"
if [ -n "$CredToken" ]; then
FeedSuffix="v2"

# Ensure there is a <packageSourceCredentials>...</packageSourceCredentials> section.
grep -i "<packageSourceCredentials>" $ConfigFile
if [ "$?" != "0" ]; then
echo "Adding dotnet3.1-internal to the packageSources."
PackageSourcesNodeFooter="</packageSources>"
PackageSourceTemplate="${TB}<add key=\"dotnet3.1-internal\" value=\"https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal/nuget/v2\" />"
echo "Adding <packageSourceCredentials>...</packageSourceCredentials> section."

sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourceTemplate${NL}$PackageSourcesNodeFooter|" $ConfigFile
fi
PackageSources+=('dotnet3.1-internal')

grep -i "<add key=\"dotnet3.1-internal-transport\">" $ConfigFile
if [ "$?" != "0" ]; then
echo "Adding dotnet3.1-internal-transport to the packageSources."
PackageSourcesNodeFooter="</packageSources>"
PackageSourceTemplate="${TB}<add key=\"dotnet3.1-internal-transport\" value=\"https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal-transport/nuget/v2\" />"
PackageSourceCredentialsTemplate="${TB}<packageSourceCredentials>${NL}${TB}</packageSourceCredentials>"

sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourceTemplate${NL}$PackageSourcesNodeFooter|" $ConfigFile
sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourcesNodeFooter${NL}$PackageSourceCredentialsTemplate|" $ConfigFile
fi
PackageSources+=('dotnet3.1-internal-transport')
fi

DotNetVersions=('5' '6' '7' '8' '9')
# Check for disabledPackageSources; we'll enable any darc-int ones we find there
grep -i "<disabledPackageSources>" $ConfigFile > /dev/null
if [ "$?" == "0" ]; then
echo "Checking for any darc-int disabled package sources in the disabledPackageSources node"
EnableMaestroInternalPackageSources
fi

DotNetVersions=('5' '6' '7' '8' '9' '10')

for DotNetVersion in ${DotNetVersions[@]} ; do
FeedPrefix="dotnet${DotNetVersion}";
grep -i "<add key=\"$FeedPrefix\"" $ConfigFile
grep -i "<add key=\"$FeedPrefix\"" $ConfigFile > /dev/null
if [ "$?" == "0" ]; then
grep -i "<add key=\"$FeedPrefix-internal\"" $ConfigFile
if [ "$?" != "0" ]; then
echo "Adding $FeedPrefix-internal to the packageSources."
PackageSourcesNodeFooter="</packageSources>"
PackageSourceTemplate="${TB}<add key=\"$FeedPrefix-internal\" value=\"https://pkgs.dev.azure.com/dnceng/internal/_packaging/$FeedPrefix-internal/nuget/v2\" />"

sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourceTemplate${NL}$PackageSourcesNodeFooter|" $ConfigFile
fi
PackageSources+=("$FeedPrefix-internal")

grep -i "<add key=\"$FeedPrefix-internal-transport\">" $ConfigFile
if [ "$?" != "0" ]; then
echo "Adding $FeedPrefix-internal-transport to the packageSources."
PackageSourcesNodeFooter="</packageSources>"
PackageSourceTemplate="${TB}<add key=\"$FeedPrefix-internal-transport\" value=\"https://pkgs.dev.azure.com/dnceng/internal/_packaging/$FeedPrefix-internal-transport/nuget/v2\" />"

sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourceTemplate${NL}$PackageSourcesNodeFooter|" $ConfigFile
fi
PackageSources+=("$FeedPrefix-internal-transport")
AddOrEnablePackageSource "$FeedPrefix-internal" "https://pkgs.dev.azure.com/dnceng/internal/_packaging/$FeedPrefix-internal/nuget/$FeedSuffix"
AddOrEnablePackageSource "$FeedPrefix-internal-transport" "https://pkgs.dev.azure.com/dnceng/internal/_packaging/$FeedPrefix-internal-transport/nuget/$FeedSuffix"
fi
done

Expand All @@ -139,29 +185,12 @@ if [ "$CredToken" ]; then
# Check if there is no existing credential for this FeedName
grep -i "<$FeedName>" $ConfigFile
if [ "$?" != "0" ]; then
echo "Adding credentials for $FeedName."
echo " Inserting credential for feed: $FeedName"

PackageSourceCredentialsNodeFooter="</packageSourceCredentials>"
NewCredential="${TB}${TB}<$FeedName>${NL}<add key=\"Username\" value=\"dn-bot\" />${NL}<add key=\"ClearTextPassword\" value=\"$CredToken\" />${NL}</$FeedName>"
NewCredential="${TB}${TB}<$FeedName>${NL}${TB}<add key=\"Username\" value=\"dn-bot\" />${NL}${TB}${TB}<add key=\"ClearTextPassword\" value=\"$CredToken\" />${NL}${TB}${TB}</$FeedName>"

sed -i.bak "s|$PackageSourceCredentialsNodeFooter|$NewCredential${NL}$PackageSourceCredentialsNodeFooter|" $ConfigFile
fi
done
fi

# Re-enable any entries in disabledPackageSources where the feed name contains darc-int
grep -i "<disabledPackageSources>" $ConfigFile
if [ "$?" == "0" ]; then
DisabledDarcIntSources=()
echo "Re-enabling any disabled \"darc-int\" package sources in $ConfigFile"
DisabledDarcIntSources+=$(grep -oh '"darc-int-[^"]*" value="true"' $ConfigFile | tr -d '"')
for DisabledSourceName in ${DisabledDarcIntSources[@]} ; do
if [[ $DisabledSourceName == darc-int* ]]
then
OldDisableValue="<add key=\"$DisabledSourceName\" value=\"true\" />"
NewDisableValue="<!-- Reenabled for build : $DisabledSourceName -->"
sed -i.bak "s|$OldDisableValue|$NewDisableValue|" $ConfigFile
echo "Neutralized disablePackageSources entry for '$DisabledSourceName'"
fi
done
fi
Loading
Loading