Skip to content

Commit cb665a5

Browse files
authored
Fix sync alias issue and replace .NET SDK version from 8.0.x with 8.x (#27335)
1 parent 01558e6 commit cb665a5

11 files changed

+105
-109
lines changed

.azure-pipelines/azure-powershell-ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
displayName: 'Use .NET SDK for Build'
9696
inputs:
9797
packageType: sdk
98-
version: 8.0.x
98+
version: 8.x
9999
- task: NodeTool@0
100100
displayName: Install Autorest
101101
inputs:
@@ -228,7 +228,7 @@ jobs:
228228
displayName: 'Use .NET SDK for Static Analysis'
229229
inputs:
230230
packageType: sdk
231-
version: 8.0.x
231+
version: 8.x
232232
- task: PowerShell@2
233233
displayName: 'Analyze'
234234
inputs:
@@ -270,7 +270,7 @@ jobs:
270270
displayName: 'Use .NET SDK for Test'
271271
inputs:
272272
packageType: sdk
273-
version: 8.0.x
273+
version: 8.x
274274
- task: PowerShell@2
275275
displayName: 'Test'
276276
inputs:

.azure-pipelines/daily-build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
displayName: 'Use .NET SDK'
3232
inputs:
3333
packageType: sdk
34-
version: 8.0.x
34+
version: 8.x
3535
- task: PowerShell@2
3636
displayName: Prepare Powershell $(PSVersion)
3737
inputs:

.azure-pipelines/powershell-core.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
displayName: 'Use .NET SDK for Build'
4444
inputs:
4545
packageType: sdk
46-
version: 8.0.x
46+
version: 8.x
4747
- task: NodeTool@0
4848
displayName: Install Autorest
4949
inputs:
@@ -121,7 +121,7 @@ jobs:
121121
displayName: 'Use .NET SDK for Static Analysis'
122122
inputs:
123123
packageType: sdk
124-
version: 8.0.x
124+
version: 8.x
125125
- task: PowerShell@2
126126
displayName: 'Analyze'
127127
inputs:
@@ -163,7 +163,7 @@ jobs:
163163
displayName: 'Use .NET SDK for Test'
164164
inputs:
165165
packageType: sdk
166-
version: 8.0.x
166+
version: 8.x
167167
- task: PowerShell@2
168168
displayName: 'Test'
169169
inputs:

.azure-pipelines/security-tools.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
displayName: 'Use .NET SDK 8.0 for Build'
2424
inputs:
2525
packageType: sdk
26-
version: 8.0.x
26+
version: 8.x
2727
- task: NodeTool@0
2828
displayName: Install Autorest
2929
inputs:
@@ -84,7 +84,7 @@ jobs:
8484
displayName: 'Use .NET SDK 6.0 for CredScan'
8585
inputs:
8686
packageType: sdk
87-
version: 6.0.x
87+
version: 6.x
8888
- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@3
8989
displayName: Run CredScan
9090
inputs:

.azure-pipelines/sync-aliases.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
displayName: Install .NET SDK
2727
inputs:
2828
packageType: sdk
29-
version: 8.0.x
29+
version: 8.x
3030

3131
- pwsh: |
3232
dotnet --version

.azure-pipelines/test-coverage.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ parameters:
22
- name: dotnet_sdk
33
displayName: .NET SDK
44
type: string
5-
default: 8.0.x
5+
default: 8.x
66
- name: testFramework
77
displayName: Test Framework
88
type: string

.azure-pipelines/util/analyze-steps.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ steps:
3030
displayName: 'Use .NET SDK'
3131
inputs:
3232
packageType: sdk
33-
version: 8.0.x
33+
version: 8.x
3434

3535
- pwsh: 'Install-Module "platyPS", "PSScriptAnalyzer" -Force -Confirm:$false -Scope CurrentUser'
3636
displayName: 'Install PowerShell Dependencies'

.azure-pipelines/util/build-steps.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ steps:
1212
displayName: 'Use .NET SDK'
1313
inputs:
1414
packageType: sdk
15-
version: 8.0.x
15+
version: 8.x
1616
- task: DotNetCoreCLI@2
1717
displayName: Filter changed files
1818
inputs:

.azure-pipelines/util/test-steps.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ steps:
1414
displayName: 'Use .NET SDK'
1515
inputs:
1616
packageType: sdk
17-
version: 8.0.x
17+
version: 8.x
1818

1919
- task: PowerShell@2
2020
displayName: Remove pre-installed Az modules

.azure-pipelines/windows-powershell.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
displayName: 'Use .NET SDK for Build'
4040
inputs:
4141
packageType: sdk
42-
version: 8.0.x
42+
version: 8.x
4343
- task: NodeTool@0
4444
displayName: Install Autorest
4545
inputs:
@@ -117,7 +117,7 @@ jobs:
117117
displayName: 'Use .NET SDK for Static Analysis'
118118
inputs:
119119
packageType: sdk
120-
version: 8.0.x
120+
version: 8.x
121121
- task: PowerShell@2
122122
displayName: 'Analyze'
123123
inputs:
@@ -142,7 +142,7 @@ jobs:
142142
displayName: 'Use .NET SDK for Test'
143143
inputs:
144144
packageType: sdk
145-
version: 8.0.x
145+
version: 8.x
146146
- task: PowerShell@2
147147
displayName: 'Test'
148148
inputs:

tools/Github/ParseServiceContactsList.ps1

+88-92
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,18 @@ function InitializeRequiredPackages {
2626
[CmdletBinding()]
2727
param ()
2828

29-
$packagesDirectoryName = "JsonYamlPackages"
30-
$packagesDirectory = Join-Path -Path . -ChildPath $packagesDirectoryName
31-
if (Test-Path -LiteralPath $packagesDirectory) {
32-
Remove-Item -LiteralPath $packagesDirectory -Recurse -Force
29+
if (-not (Get-PackageProvider -Name NuGet -ErrorAction SilentlyContinue)) {
30+
Install-PackageProvider -Name NuGet -Force
3331
}
3432

35-
New-Item -Path . -Name $packagesDirectoryName -ItemType Directory -Force
36-
37-
$requiredPackages = @(
38-
@{ PackageName = "Newtonsoft.Json"; PackageVersion = "13.0.2"; DllName = "Newtonsoft.Json.dll" },
39-
@{ PackageName = "YamlDotNet"; PackageVersion = "13.2.0"; DllName = "YamlDotNet.dll" }
40-
)
41-
42-
$requiredPackages | ForEach-Object {
43-
$packageName = $_["PackageName"]
44-
$packageVersion = $_["PackageVersion"]
45-
$packageDll = $_["DllName"]
46-
Install-Package -Name $packageName -RequiredVersion $packageVersion -Source "https://www.nuget.org/api/v2" -Destination $packagesDirectory -SkipDependencies -ExcludeVersion -Force
47-
Add-Type -LiteralPath (Join-Path -Path $packagesDirectory -ChildPath $packageName | Join-Path -ChildPath "lib" | Join-Path -ChildPath "net8.0" | Join-Path -ChildPath $packageDll) -ErrorAction SilentlyContinue
48-
}
33+
Install-Package -Name YamlDotNet -RequiredVersion ${env:YamlDotNetVersion} -ProviderName NuGet -Force
34+
$pkgYaml = Get-Package -Name YamlDotNet | Select-Object -ExpandProperty Source | Split-Path
35+
$dllYaml = Join-Path -Path $pkgYaml -ChildPath "lib" | Join-Path -ChildPath "netstandard2.0" | Join-Path -ChildPath "YamlDotNet.dll"
36+
Add-Type -LiteralPath $dllYaml
4937
}
5038

39+
$ErrorActionPreference = "Stop"
40+
5141
# get wiki content
5242
$username = ""
5343
$password = $AccessToken
@@ -58,89 +48,95 @@ $headers = @{
5848
Authorization = "Basic {0}" -f ($token)
5949
}
6050

61-
$response = Invoke-RestMethod 'https://dev.azure.com/azclitools/internal/_apis/wiki/wikis/internal.wiki/pages?path=/Service%20Contact%20List&includeContent=true' -Headers $headers -ErrorAction Stop
62-
$contactsList = ($response.content -split "\n") | Where-Object { $_ -like '|*' } | Select-Object -Skip 2
63-
64-
if ($null -ne $contactsList) {
65-
$idxServiceTeamLabel = 2
66-
$idxPSNotifyGithubHandler = 6
67-
$serviceContacts = [System.Collections.Generic.SortedList[System.String, PSCustomObject]]::new()
68-
69-
foreach ($contacts in $contactsList) {
70-
$items = $contacts -split "\|"
71-
$colServiceTeamLabel = $items[$idxServiceTeamLabel]
72-
if (![string]::IsNullOrWhiteSpace($colServiceTeamLabel)) {
73-
$serviceTeamLabel = $colServiceTeamLabel.Trim()
74-
$colPSNotifyGithubHandler = $items[$idxPSNotifyGithubHandler]
75-
76-
if (![string]::IsNullOrWhiteSpace($colPSNotifyGithubHandler)) {
77-
$psNotifyGithubHandler = $colPSNotifyGithubHandler.Trim()
78-
[array]$mentionees = $psNotifyGithubHandler.Split(",", [StringSplitOptions]::RemoveEmptyEntries) | ForEach-Object {
79-
$_.Trim()
80-
}
81-
82-
$serviceContacts.Add($serviceTeamLabel, [PSCustomObject]@{
83-
if = @(
84-
[PSCustomObject]@{
85-
or = @(
86-
[PSCustomObject]@{
87-
labelAdded = [PSCustomObject]@{
88-
label = 'Service Attention'
89-
}
90-
},
91-
[PSCustomObject]@{
92-
labelAdded = [PSCustomObject]@{
93-
label = $serviceTeamLabel
51+
try {
52+
$response = Invoke-RestMethod ${env:ServiceContactsListUrl} -Headers $headers -ErrorAction Stop
53+
$contactsList = ($response.content -split "\n") | Where-Object { $_ -like '|*' } | Select-Object -Skip 2
54+
55+
if ($null -ne $contactsList) {
56+
$idxServiceTeamLabel = 2
57+
$idxPSNotifyGithubHandler = 6
58+
$serviceContacts = [System.Collections.Generic.SortedList[System.String, PSCustomObject]]::new()
59+
60+
foreach ($contacts in $contactsList) {
61+
$items = $contacts -split "\|"
62+
$colServiceTeamLabel = $items[$idxServiceTeamLabel]
63+
if (![string]::IsNullOrWhiteSpace($colServiceTeamLabel)) {
64+
$serviceTeamLabel = $colServiceTeamLabel.Trim()
65+
$colPSNotifyGithubHandler = $items[$idxPSNotifyGithubHandler]
66+
67+
if (![string]::IsNullOrWhiteSpace($colPSNotifyGithubHandler)) {
68+
$psNotifyGithubHandler = $colPSNotifyGithubHandler.Trim()
69+
[array]$mentionees = $psNotifyGithubHandler.Split(",", [StringSplitOptions]::RemoveEmptyEntries) | ForEach-Object {
70+
$_.Trim()
71+
}
72+
73+
$serviceContacts.Add($serviceTeamLabel, [PSCustomObject]@{
74+
if = @(
75+
[PSCustomObject]@{
76+
or = @(
77+
[PSCustomObject]@{
78+
labelAdded = [PSCustomObject]@{
79+
label = 'Service Attention'
80+
}
81+
},
82+
[PSCustomObject]@{
83+
labelAdded = [PSCustomObject]@{
84+
label = $serviceTeamLabel
85+
}
9486
}
87+
)
88+
},
89+
[PSCustomObject]@{
90+
hasLabel = [PSCustomObject]@{
91+
label = 'Service Attention'
92+
}
93+
},
94+
[PSCustomObject]@{
95+
hasLabel = [PSCustomObject]@{
96+
label = $serviceTeamLabel
9597
}
96-
)
97-
},
98-
[PSCustomObject]@{
99-
hasLabel = [PSCustomObject]@{
100-
label = 'Service Attention'
101-
}
102-
},
103-
[PSCustomObject]@{
104-
hasLabel = [PSCustomObject]@{
105-
label = $serviceTeamLabel
10698
}
107-
}
108-
)
109-
then = @(
110-
[PSCustomObject]@{
111-
mentionUsers = [PSCustomObject]@{
112-
mentionees = $mentionees
113-
replyTemplate = 'Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc ${mentionees}.'
114-
assignMentionees = 'False'
99+
)
100+
then = @(
101+
[PSCustomObject]@{
102+
mentionUsers = [PSCustomObject]@{
103+
mentionees = $mentionees
104+
replyTemplate = 'Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc ${mentionees}.'
105+
assignMentionees = 'False'
106+
}
115107
}
116-
}
117-
)
118-
})
108+
)
109+
})
110+
}
119111
}
120112
}
121113
}
122-
}
123114

124-
# Update yaml file
125-
InitializeRequiredPackages
115+
# Update yaml file
116+
InitializeRequiredPackages
126117

127-
$yamlConfigPath = $PSScriptRoot | Split-Path | Split-Path | Join-Path -ChildPath ".github" | Join-Path -ChildPath "policies" | Join-Path -ChildPath "resourceManagement.yml"
128-
$yamlContent = Get-Content -Path $yamlConfigPath -Raw
129-
$yamlDeserializer = [YamlDotNet.Serialization.DeserializerBuilder]::new().Build()
130-
$yamlObjectGraph = $yamlDeserializer.Deserialize($yamlContent)
131-
$jsonSerializer = [YamlDotNet.Serialization.SerializerBuilder]::new().JsonCompatible().Build()
132-
$jsonObjectGraph = $jsonSerializer.Serialize($yamlObjectGraph) | ConvertFrom-Json
118+
$yamlConfigPath = $PSScriptRoot | Split-Path | Split-Path | Join-Path -ChildPath ".github" | Join-Path -ChildPath "policies" | Join-Path -ChildPath "resourceManagement.yml"
119+
$yamlContent = Get-Content -Path $yamlConfigPath -Raw
120+
$yamlDeserializer = [YamlDotNet.Serialization.DeserializerBuilder]::new().Build()
121+
$yamlObjectGraph = $yamlDeserializer.Deserialize($yamlContent)
122+
$jsonSerializer = [YamlDotNet.Serialization.SerializerBuilder]::new().JsonCompatible().Build()
123+
$jsonObjectGraph = $jsonSerializer.Serialize($yamlObjectGraph) | ConvertFrom-Json
133124

134-
$serviceContactsTask = $jsonObjectGraph.configuration.resourceManagementConfiguration.eventResponderTasks | Where-Object { $_.description -eq "Triage issues to the service team" }
135-
if ($null -ne $serviceContactsTask) {
136-
$serviceContactsTask.then = $serviceContacts.Values
137-
}
125+
$serviceContactsTask = $jsonObjectGraph.configuration.resourceManagementConfiguration.eventResponderTasks | Where-Object { $_.description -eq "Triage issues to the service team" }
126+
if ($null -ne $serviceContactsTask) {
127+
$serviceContactsTask.then = $serviceContacts.Values
128+
}
138129

139-
$updatedJsonContent = $jsonObjectGraph | ConvertTo-Json -Depth 64
140-
$updatedJsonObjectGraph = [Newtonsoft.Json.JsonConvert]::DeserializeObject[System.Dynamic.ExpandoObject]($updatedJsonContent)
141-
$yamlSerializer = [YamlDotNet.Serialization.SerializerBuilder]::new().Build()
142-
$updatedYamlContent = $yamlSerializer.Serialize($updatedJsonObjectGraph)
143-
$updatedYamlContent | Out-File -FilePath $yamlConfigPath -NoNewline -Force
130+
$updatedJsonContent = $jsonObjectGraph | ConvertTo-Json -Depth 64
131+
$updatedJsonObjectGraph = [Newtonsoft.Json.JsonConvert]::DeserializeObject[System.Dynamic.ExpandoObject]($updatedJsonContent)
132+
$yamlSerializer = [YamlDotNet.Serialization.SerializerBuilder]::new().Build()
133+
$updatedYamlContent = $yamlSerializer.Serialize($updatedJsonObjectGraph)
134+
$updatedYamlContent | Out-File -FilePath $yamlConfigPath -NoNewline -Force
144135

145-
# Remove trailing space on each line
146-
(Get-Content -Path $yamlConfigPath) | ForEach-Object { $_.TrimEnd() } | Set-Content -Path $yamlConfigPath
136+
# Remove trailing space on each line
137+
(Get-Content -Path $yamlConfigPath) | ForEach-Object { $_.TrimEnd() } | Set-Content -Path $yamlConfigPath
138+
}
139+
catch {
140+
Write-Error "Error occurred while updating the resourceManagement.yml file. Error Message: $($_.Exception.Message)"
141+
throw
142+
}

0 commit comments

Comments
 (0)