@@ -39,7 +39,7 @@ class PackageProps
3939 if (Test-Path (Join-Path $directoryPath " README.md" ))
4040 {
4141 $this.ReadMePath = Join-Path $directoryPath " README.md"
42- }
42+ }
4343 else
4444 {
4545 $this.ReadMePath = $null
@@ -48,7 +48,7 @@ class PackageProps
4848 if (Test-Path (Join-Path $directoryPath " CHANGELOG.md" ))
4949 {
5050 $this.ChangeLogPath = Join-Path $directoryPath " CHANGELOG.md"
51- }
51+ }
5252 else
5353 {
5454 $this.ChangeLogPath = $null
@@ -81,17 +81,19 @@ function Get-PkgProperties
8181 [string ]$ServiceDirectory
8282 )
8383
84- $AllPkgProps = Get-AllPkgProperties - ServiceDirectory $ServiceDirectory
84+ $allPkgProps = Get-AllPkgProperties - ServiceDirectory $ServiceDirectory
85+ $pkgProps = $allPkgProps.Where ({ $_.Name -eq $PackageName -or $_.ArtifactName -eq $PackageName });
8586
86- foreach ($pkgProp in $AllPkgProps )
87+ if ($pkgProps .Count -ge 1 )
8788 {
88- if (( $pkgProp .Name -eq $PackageName ) -or ( $pkgProp .ArtifactName -eq $PackageName ) )
89+ if ( $pkgProps .Count -gt 1 )
8990 {
90- return $pkgProp
91+ Write-Host " Found more than one project with the name [ $PackageName ], choosing the first one under $ ( $pkgProps [ 0 ].DirectoryPath ) "
9192 }
93+ return $pkgProps [0 ]
9294 }
9395
94- LogError " Failed to retrive Properties for [ $PackageName ]"
96+ LogError " Failed to retrive Properties for [$PackageName ]"
9597 return $null
9698}
9799
@@ -114,7 +116,7 @@ function Get-AllPkgProperties ([string]$ServiceDirectory = $null)
114116 {
115117 $pkgPropsResult += Get-PkgPropsForEntireService - serviceDirectoryPath $dir.FullName
116118 }
117- }
119+ }
118120 else
119121 {
120122 $pkgPropsResult = Get-PkgPropsForEntireService - serviceDirectoryPath (Join-Path $RepoRoot " sdk" $ServiceDirectory )
@@ -124,7 +126,7 @@ function Get-AllPkgProperties ([string]$ServiceDirectory = $null)
124126 return $pkgPropsResult
125127}
126128
127- # Given the metadata url under https://github.com/Azure/azure-sdk/tree/master/_data/releases/latest,
129+ # Given the metadata url under https://github.com/Azure/azure-sdk/tree/master/_data/releases/latest,
128130# the function will return the csv metadata back as part of response.
129131function Get-CSVMetadata ([string ]$MetadataUri = $MetadataUri )
130132{
@@ -135,8 +137,7 @@ function Get-CSVMetadata ([string]$MetadataUri=$MetadataUri)
135137function Get-PkgPropsForEntireService ($serviceDirectoryPath )
136138{
137139 $projectProps = @ () # Properties from very project inthe service
138- $packageProps = @ () # Properties for artifacts specified in ci.yml
139- $serviceDirectory = (Split-Path - Path $serviceDirectoryPath - Leaf)
140+ $serviceDirectory = $serviceDirectoryPath -replace ' ^.*[\\/]+sdk[\\/]+([^\\/]+).*$' , ' $1'
140141
141142 if (! $GetPackageInfoFromRepoFn -or ! (Test-Path " Function:$GetPackageInfoFromRepoFn " ))
142143 {
@@ -147,49 +148,12 @@ function Get-PkgPropsForEntireService ($serviceDirectoryPath)
147148
148149 foreach ($directory in (Get-ChildItem $serviceDirectoryPath - Directory))
149150 {
150- $pkgDirectoryPath = Join-Path $serviceDirectoryPath $directory.Name
151- $pkgProps = & $GetPackageInfoFromRepoFn $pkgDirectoryPath $serviceDirectory
152- if ($null -ne $pkgProps )
151+ $pkgProps = & $GetPackageInfoFromRepoFn $directory.FullName $serviceDirectory
152+ if ($null -ne $pkgProps )
153153 {
154154 $projectProps += $pkgProps
155155 }
156156 }
157157
158- $ciYmlFiles = Get-ChildItem $serviceDirectoryPath - filter " ci.yml"
159- foreach ($ciYmlFile in $ciYmlFiles )
160- {
161- $activeArtifactList = Get-ArtifactListFromYml - ciYmlPath $ciYmlFile.FullName
162- foreach ($artifact in $activeArtifactList )
163- {
164- $packageProps += $projectProps | Where-Object { $_.ArtifactName -eq $artifact [" name" ] -and $_.Group -eq $artifact [" groupId" ] }
165- }
166- }
167-
168- return $packageProps
169- }
170-
171- function Get-ArtifactListFromYml ($ciYmlPath )
172- {
173- $ProgressPreference = " SilentlyContinue"
174- if ((Get-PSRepository ).Where ({$_.Name -eq " PSGallery" }).Count -eq 0 )
175- {
176- Register-PSRepository - Default - ErrorAction:SilentlyContinue
177- }
178-
179- if ((Get-Module - ListAvailable - Name powershell- yaml).Where ({ $_.Version -eq " 0.4.2" } ).Count -eq 0 )
180- {
181- Install-Module - Name powershell- yaml - RequiredVersion 0.4 .2 - Force - Scope CurrentUser
182- }
183-
184- $ciYmlContent = Get-Content $ciYmlPath - Raw
185- $ciYmlObj = ConvertFrom-Yaml $ciYmlContent - Ordered
186- if ($ciYmlObj.Contains (" stages" ))
187- {
188- $artifactsInCI = $ciYmlObj [" stages" ][0 ][" parameters" ][" Artifacts" ]
189- }
190- elseif ($ciYmlObj.Contains (" extends" ))
191- {
192- $artifactsInCI = $ciYmlObj [" extends" ][" parameters" ][" Artifacts" ]
193- }
194- return $artifactsInCI
158+ return $projectProps
195159}
0 commit comments