Skip to content

Commit 2c7ed86

Browse files
authored
Merge pull request #9022 from dotnet/merge/release/9.0.3xx-to-main
[automated] Merge branch 'release/9.0.3xx' => 'main'
2 parents 768eef3 + 359dad5 commit 2c7ed86

File tree

115 files changed

+6502
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+6502
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"RetryCountLimit": 1,
3+
"RetryByAnyError": false
4+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@{
2+
IncludeRules=@('PSAvoidUsingCmdletAliases',
3+
'PSAvoidUsingWMICmdlet',
4+
'PSAvoidUsingPositionalParameters',
5+
'PSAvoidUsingInvokeExpression',
6+
'PSUseDeclaredVarsMoreThanAssignments',
7+
'PSUseCmdletCorrectly',
8+
'PSStandardDSCFunctionsInResource',
9+
'PSUseIdenticalMandatoryParametersForDSC',
10+
'PSUseIdenticalParametersForDSC')
11+
}

src/arcade/eng/common/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Don't touch this folder
2+
3+
uuuuuuuuuuuuuuuuuuuu
4+
u" uuuuuuuuuuuuuuuuuu "u
5+
u" u$$$$$$$$$$$$$$$$$$$$u "u
6+
u" u$$$$$$$$$$$$$$$$$$$$$$$$u "u
7+
u" u$$$$$$$$$$$$$$$$$$$$$$$$$$$$u "u
8+
u" u$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$u "u
9+
u" u$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$u "u
10+
$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $
11+
$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $
12+
$ $$$" ... "$... ...$" ... "$$$ ... "$$$ $
13+
$ $$$u `"$$$$$$$ $$$ $$$$$ $$ $$$ $$$ $
14+
$ $$$$$$uu "$$$$ $$$ $$$$$ $$ """ u$$$ $
15+
$ $$$""$$$ $$$$ $$$u "$$$" u$$ $$$$$$$$ $
16+
$ $$$$....,$$$$$..$$$$$....,$$$$..$$$$$$$$ $
17+
$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $
18+
"u "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" u"
19+
"u "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" u"
20+
"u "$$$$$$$$$$$$$$$$$$$$$$$$$$$$" u"
21+
"u "$$$$$$$$$$$$$$$$$$$$$$$$" u"
22+
"u "$$$$$$$$$$$$$$$$$$$$" u"
23+
"u """""""""""""""""" u"
24+
""""""""""""""""""""
25+
26+
!!! Changes made in this directory are subject to being overwritten by automation !!!
27+
28+
The files in this directory are shared by all Arcade repos and managed by automation. If you need to make changes to these files, open an issue or submit a pull request to https://github.com/dotnet/arcade first.
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# This script adds internal feeds required to build commits that depend on internal package sources. For instance,
2+
# dotnet6-internal would be added automatically if dotnet6 was found in the nuget.config file. In addition also enables
3+
# disabled internal Maestro (darc-int*) feeds.
4+
#
5+
# Optionally, this script also adds a credential entry for each of the internal feeds if supplied.
6+
#
7+
# See example call for this script below.
8+
#
9+
# - task: PowerShell@2
10+
# displayName: Setup Private Feeds Credentials
11+
# condition: eq(variables['Agent.OS'], 'Windows_NT')
12+
# inputs:
13+
# filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.ps1
14+
# arguments: -ConfigFile $(Build.SourcesDirectory)/NuGet.config -Password $Env:Token
15+
# env:
16+
# Token: $(dn-bot-dnceng-artifact-feeds-rw)
17+
#
18+
# Note that the NuGetAuthenticate task should be called after SetupNugetSources.
19+
# This ensures that:
20+
# - Appropriate creds are set for the added internal feeds (if not supplied to the scrupt)
21+
# - The credential provider is installed.
22+
#
23+
# This logic is also abstracted into enable-internal-sources.yml.
24+
25+
[CmdletBinding()]
26+
param (
27+
[Parameter(Mandatory = $true)][string]$ConfigFile,
28+
$Password
29+
)
30+
31+
$ErrorActionPreference = "Stop"
32+
Set-StrictMode -Version 2.0
33+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
34+
35+
. $PSScriptRoot\tools.ps1
36+
37+
# Add source entry to PackageSources
38+
function AddPackageSource($sources, $SourceName, $SourceEndPoint, $creds, $Username, $pwd) {
39+
$packageSource = $sources.SelectSingleNode("add[@key='$SourceName']")
40+
41+
if ($packageSource -eq $null)
42+
{
43+
$packageSource = $doc.CreateElement("add")
44+
$packageSource.SetAttribute("key", $SourceName)
45+
$packageSource.SetAttribute("value", $SourceEndPoint)
46+
$sources.AppendChild($packageSource) | Out-Null
47+
}
48+
else {
49+
Write-Host "Package source $SourceName already present."
50+
}
51+
52+
AddCredential -Creds $creds -Source $SourceName -Username $Username -pwd $pwd
53+
}
54+
55+
# Add a credential node for the specified source
56+
function AddCredential($creds, $source, $username, $pwd) {
57+
# If no cred supplied, don't do anything.
58+
if (!$pwd) {
59+
return;
60+
}
61+
62+
# Looks for credential configuration for the given SourceName. Create it if none is found.
63+
$sourceElement = $creds.SelectSingleNode($Source)
64+
if ($sourceElement -eq $null)
65+
{
66+
$sourceElement = $doc.CreateElement($Source)
67+
$creds.AppendChild($sourceElement) | Out-Null
68+
}
69+
70+
# Add the <Username> node to the credential if none is found.
71+
$usernameElement = $sourceElement.SelectSingleNode("add[@key='Username']")
72+
if ($usernameElement -eq $null)
73+
{
74+
$usernameElement = $doc.CreateElement("add")
75+
$usernameElement.SetAttribute("key", "Username")
76+
$sourceElement.AppendChild($usernameElement) | Out-Null
77+
}
78+
$usernameElement.SetAttribute("value", $Username)
79+
80+
# Add the <ClearTextPassword> to the credential if none is found.
81+
# Add it as a clear text because there is no support for encrypted ones in non-windows .Net SDKs.
82+
# -> https://github.com/NuGet/Home/issues/5526
83+
$passwordElement = $sourceElement.SelectSingleNode("add[@key='ClearTextPassword']")
84+
if ($passwordElement -eq $null)
85+
{
86+
$passwordElement = $doc.CreateElement("add")
87+
$passwordElement.SetAttribute("key", "ClearTextPassword")
88+
$sourceElement.AppendChild($passwordElement) | Out-Null
89+
}
90+
91+
$passwordElement.SetAttribute("value", $pwd)
92+
}
93+
94+
function InsertMaestroPrivateFeedCredentials($Sources, $Creds, $Username, $pwd) {
95+
$maestroPrivateSources = $Sources.SelectNodes("add[contains(@key,'darc-int')]")
96+
97+
Write-Host "Inserting credentials for $($maestroPrivateSources.Count) Maestro's private feeds."
98+
99+
ForEach ($PackageSource in $maestroPrivateSources) {
100+
Write-Host "`tInserting credential for Maestro's feed:" $PackageSource.Key
101+
AddCredential -Creds $creds -Source $PackageSource.Key -Username $Username -pwd $pwd
102+
}
103+
}
104+
105+
function EnablePrivatePackageSources($DisabledPackageSources) {
106+
$maestroPrivateSources = $DisabledPackageSources.SelectNodes("add[contains(@key,'darc-int')]")
107+
ForEach ($DisabledPackageSource in $maestroPrivateSources) {
108+
Write-Host "`tEnsuring private source '$($DisabledPackageSource.key)' is enabled by deleting it from disabledPackageSource"
109+
# Due to https://github.com/NuGet/Home/issues/10291, we must actually remove the disabled entries
110+
$DisabledPackageSources.RemoveChild($DisabledPackageSource)
111+
}
112+
}
113+
114+
if (!(Test-Path $ConfigFile -PathType Leaf)) {
115+
Write-PipelineTelemetryError -Category 'Build' -Message "Eng/common/SetupNugetSources.ps1 returned a non-zero exit code. Couldn't find the NuGet config file: $ConfigFile"
116+
ExitWithExitCode 1
117+
}
118+
119+
# Load NuGet.config
120+
$doc = New-Object System.Xml.XmlDocument
121+
$filename = (Get-Item $ConfigFile).FullName
122+
$doc.Load($filename)
123+
124+
# Get reference to <PackageSources> or create one if none exist already
125+
$sources = $doc.DocumentElement.SelectSingleNode("packageSources")
126+
if ($sources -eq $null) {
127+
$sources = $doc.CreateElement("packageSources")
128+
$doc.DocumentElement.AppendChild($sources) | Out-Null
129+
}
130+
131+
$creds = $null
132+
if ($Password) {
133+
# Looks for a <PackageSourceCredentials> node. Create it if none is found.
134+
$creds = $doc.DocumentElement.SelectSingleNode("packageSourceCredentials")
135+
if ($creds -eq $null) {
136+
$creds = $doc.CreateElement("packageSourceCredentials")
137+
$doc.DocumentElement.AppendChild($creds) | Out-Null
138+
}
139+
}
140+
141+
# Check for disabledPackageSources; we'll enable any darc-int ones we find there
142+
$disabledSources = $doc.DocumentElement.SelectSingleNode("disabledPackageSources")
143+
if ($disabledSources -ne $null) {
144+
Write-Host "Checking for any darc-int disabled package sources in the disabledPackageSources node"
145+
EnablePrivatePackageSources -DisabledPackageSources $disabledSources
146+
}
147+
148+
$userName = "dn-bot"
149+
150+
# Insert credential nodes for Maestro's private feeds
151+
InsertMaestroPrivateFeedCredentials -Sources $sources -Creds $creds -Username $userName -pwd $Password
152+
153+
# 3.1 uses a different feed url format so it's handled differently here
154+
$dotnet31Source = $sources.SelectSingleNode("add[@key='dotnet3.1']")
155+
if ($dotnet31Source -ne $null) {
156+
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
157+
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
158+
}
159+
160+
$dotnetVersions = @('5','6','7','8','9')
161+
162+
foreach ($dotnetVersion in $dotnetVersions) {
163+
$feedPrefix = "dotnet" + $dotnetVersion;
164+
$dotnetSource = $sources.SelectSingleNode("add[@key='$feedPrefix']")
165+
if ($dotnetSource -ne $null) {
166+
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
167+
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
168+
}
169+
}
170+
171+
$doc.Save($filename)
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
#!/usr/bin/env bash
2+
3+
# This script adds internal feeds required to build commits that depend on internal package sources. For instance,
4+
# dotnet6-internal would be added automatically if dotnet6 was found in the nuget.config file. In addition also enables
5+
# disabled internal Maestro (darc-int*) feeds.
6+
#
7+
# Optionally, this script also adds a credential entry for each of the internal feeds if supplied.
8+
#
9+
# See example call for this script below.
10+
#
11+
# - task: Bash@3
12+
# displayName: Setup Internal Feeds
13+
# inputs:
14+
# filePath: $(Build.SourcesDirectory)/eng/common/SetupNugetSources.sh
15+
# arguments: $(Build.SourcesDirectory)/NuGet.config
16+
# condition: ne(variables['Agent.OS'], 'Windows_NT')
17+
# - task: NuGetAuthenticate@1
18+
#
19+
# Note that the NuGetAuthenticate task should be called after SetupNugetSources.
20+
# This ensures that:
21+
# - Appropriate creds are set for the added internal feeds (if not supplied to the scrupt)
22+
# - The credential provider is installed.
23+
#
24+
# This logic is also abstracted into enable-internal-sources.yml.
25+
26+
ConfigFile=$1
27+
CredToken=$2
28+
NL='\n'
29+
TB=' '
30+
31+
source="${BASH_SOURCE[0]}"
32+
33+
# resolve $source until the file is no longer a symlink
34+
while [[ -h "$source" ]]; do
35+
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
36+
source="$(readlink "$source")"
37+
# if $source was a relative symlink, we need to resolve it relative to the path where the
38+
# symlink file was located
39+
[[ $source != /* ]] && source="$scriptroot/$source"
40+
done
41+
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
42+
43+
. "$scriptroot/tools.sh"
44+
45+
if [ ! -f "$ConfigFile" ]; then
46+
Write-PipelineTelemetryError -Category 'Build' "Error: Eng/common/SetupNugetSources.sh returned a non-zero exit code. Couldn't find the NuGet config file: $ConfigFile"
47+
ExitWithExitCode 1
48+
fi
49+
50+
if [[ `uname -s` == "Darwin" ]]; then
51+
NL=$'\\\n'
52+
TB=''
53+
fi
54+
55+
# Ensure there is a <packageSources>...</packageSources> section.
56+
grep -i "<packageSources>" $ConfigFile
57+
if [ "$?" != "0" ]; then
58+
echo "Adding <packageSources>...</packageSources> section."
59+
ConfigNodeHeader="<configuration>"
60+
PackageSourcesTemplate="${TB}<packageSources>${NL}${TB}</packageSources>"
61+
62+
sed -i.bak "s|$ConfigNodeHeader|$ConfigNodeHeader${NL}$PackageSourcesTemplate|" $ConfigFile
63+
fi
64+
65+
# Ensure there is a <packageSourceCredentials>...</packageSourceCredentials> section.
66+
grep -i "<packageSourceCredentials>" $ConfigFile
67+
if [ "$?" != "0" ]; then
68+
echo "Adding <packageSourceCredentials>...</packageSourceCredentials> section."
69+
70+
PackageSourcesNodeFooter="</packageSources>"
71+
PackageSourceCredentialsTemplate="${TB}<packageSourceCredentials>${NL}${TB}</packageSourceCredentials>"
72+
73+
sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourcesNodeFooter${NL}$PackageSourceCredentialsTemplate|" $ConfigFile
74+
fi
75+
76+
PackageSources=()
77+
78+
# Ensure dotnet3.1-internal and dotnet3.1-internal-transport are in the packageSources if the public dotnet3.1 feeds are present
79+
grep -i "<add key=\"dotnet3.1\"" $ConfigFile
80+
if [ "$?" == "0" ]; then
81+
grep -i "<add key=\"dotnet3.1-internal\"" $ConfigFile
82+
if [ "$?" != "0" ]; then
83+
echo "Adding dotnet3.1-internal to the packageSources."
84+
PackageSourcesNodeFooter="</packageSources>"
85+
PackageSourceTemplate="${TB}<add key=\"dotnet3.1-internal\" value=\"https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal/nuget/v2\" />"
86+
87+
sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourceTemplate${NL}$PackageSourcesNodeFooter|" $ConfigFile
88+
fi
89+
PackageSources+=('dotnet3.1-internal')
90+
91+
grep -i "<add key=\"dotnet3.1-internal-transport\">" $ConfigFile
92+
if [ "$?" != "0" ]; then
93+
echo "Adding dotnet3.1-internal-transport to the packageSources."
94+
PackageSourcesNodeFooter="</packageSources>"
95+
PackageSourceTemplate="${TB}<add key=\"dotnet3.1-internal-transport\" value=\"https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal-transport/nuget/v2\" />"
96+
97+
sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourceTemplate${NL}$PackageSourcesNodeFooter|" $ConfigFile
98+
fi
99+
PackageSources+=('dotnet3.1-internal-transport')
100+
fi
101+
102+
DotNetVersions=('5' '6' '7' '8' '9')
103+
104+
for DotNetVersion in ${DotNetVersions[@]} ; do
105+
FeedPrefix="dotnet${DotNetVersion}";
106+
grep -i "<add key=\"$FeedPrefix\"" $ConfigFile
107+
if [ "$?" == "0" ]; then
108+
grep -i "<add key=\"$FeedPrefix-internal\"" $ConfigFile
109+
if [ "$?" != "0" ]; then
110+
echo "Adding $FeedPrefix-internal to the packageSources."
111+
PackageSourcesNodeFooter="</packageSources>"
112+
PackageSourceTemplate="${TB}<add key=\"$FeedPrefix-internal\" value=\"https://pkgs.dev.azure.com/dnceng/internal/_packaging/$FeedPrefix-internal/nuget/v2\" />"
113+
114+
sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourceTemplate${NL}$PackageSourcesNodeFooter|" $ConfigFile
115+
fi
116+
PackageSources+=("$FeedPrefix-internal")
117+
118+
grep -i "<add key=\"$FeedPrefix-internal-transport\">" $ConfigFile
119+
if [ "$?" != "0" ]; then
120+
echo "Adding $FeedPrefix-internal-transport to the packageSources."
121+
PackageSourcesNodeFooter="</packageSources>"
122+
PackageSourceTemplate="${TB}<add key=\"$FeedPrefix-internal-transport\" value=\"https://pkgs.dev.azure.com/dnceng/internal/_packaging/$FeedPrefix-internal-transport/nuget/v2\" />"
123+
124+
sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourceTemplate${NL}$PackageSourcesNodeFooter|" $ConfigFile
125+
fi
126+
PackageSources+=("$FeedPrefix-internal-transport")
127+
fi
128+
done
129+
130+
# I want things split line by line
131+
PrevIFS=$IFS
132+
IFS=$'\n'
133+
PackageSources+="$IFS"
134+
PackageSources+=$(grep -oh '"darc-int-[^"]*"' $ConfigFile | tr -d '"')
135+
IFS=$PrevIFS
136+
137+
if [ "$CredToken" ]; then
138+
for FeedName in ${PackageSources[@]} ; do
139+
# Check if there is no existing credential for this FeedName
140+
grep -i "<$FeedName>" $ConfigFile
141+
if [ "$?" != "0" ]; then
142+
echo "Adding credentials for $FeedName."
143+
144+
PackageSourceCredentialsNodeFooter="</packageSourceCredentials>"
145+
NewCredential="${TB}${TB}<$FeedName>${NL}<add key=\"Username\" value=\"dn-bot\" />${NL}<add key=\"ClearTextPassword\" value=\"$CredToken\" />${NL}</$FeedName>"
146+
147+
sed -i.bak "s|$PackageSourceCredentialsNodeFooter|$NewCredential${NL}$PackageSourceCredentialsNodeFooter|" $ConfigFile
148+
fi
149+
done
150+
fi
151+
152+
# Re-enable any entries in disabledPackageSources where the feed name contains darc-int
153+
grep -i "<disabledPackageSources>" $ConfigFile
154+
if [ "$?" == "0" ]; then
155+
DisabledDarcIntSources=()
156+
echo "Re-enabling any disabled \"darc-int\" package sources in $ConfigFile"
157+
DisabledDarcIntSources+=$(grep -oh '"darc-int-[^"]*" value="true"' $ConfigFile | tr -d '"')
158+
for DisabledSourceName in ${DisabledDarcIntSources[@]} ; do
159+
if [[ $DisabledSourceName == darc-int* ]]
160+
then
161+
OldDisableValue="<add key=\"$DisabledSourceName\" value=\"true\" />"
162+
NewDisableValue="<!-- Reenabled for build : $DisabledSourceName -->"
163+
sed -i.bak "s|$OldDisableValue|$NewDisableValue|" $ConfigFile
164+
echo "Neutralized disablePackageSources entry for '$DisabledSourceName'"
165+
fi
166+
done
167+
fi

src/arcade/eng/common/build.cmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0build.ps1""" %*"
3+
exit /b %ErrorLevel%

0 commit comments

Comments
 (0)