@@ -99,56 +99,63 @@ $exportedPaths = @{}
9999$allPackageProperties = @ ()
100100
101101if ($prDiff ) {
102+ Write-Host " Getting package properties for PR diff file: $prDiff "
102103 $allPackageProperties = Get-PrPkgProperties $prDiff
104+
105+ if (! $allPackageProperties ) {
106+ Write-Host " No packages found matching PR diff file $prDiff "
107+ Write-Host " Setting NoPackagesChanged variable to true"
108+ Write-Host " ##vso[task.setvariable variable=NoPackagesChanged]true"
109+ exit 0
110+ }
103111}
104112else {
113+ Write-Host " Getting package properties for service directory: $serviceDirectory "
105114 $allPackageProperties = Get-AllPkgProperties $serviceDirectory
115+
116+ if (! $allPackageProperties ) {
117+ Write-Error " Package properties are not available for service directory $serviceDirectory "
118+ exit 1
119+ }
120+ }
121+
122+ if (-not (Test-Path - Path $outDirectory ))
123+ {
124+ New-Item - ItemType Directory - Force - Path $outDirectory | Out-Null
106125}
107126
108- if ( $allPackageProperties )
127+ foreach ( $pkg in $allPackageProperties )
109128{
110- if (-not (Test-Path - Path $outDirectory ))
129+ if ($pkg.Name ) {
130+ Write-Host " Package Name: $ ( $pkg.Name ) "
131+ Write-Host " Package Version: $ ( $pkg.Version ) "
132+ Write-Host " Package SDK Type: $ ( $pkg.SdkType ) "
133+ Write-Host " Artifact Name: $ ( $pkg.ArtifactName ) "
134+ Write-Host " Release date: $ ( $pkg.ReleaseStatus ) "
135+ $configFilePrefix = $pkg.Name
136+ if ($pkg.ArtifactName )
111137 {
112- New-Item - ItemType Directory - Force - Path $outDirectory
138+ $configFilePrefix = $pkg .ArtifactName
113139 }
114- foreach ($pkg in $allPackageProperties )
140+ $outputPath = Join-Path - Path $outDirectory " $configFilePrefix .json"
141+ Write-Host " Output path of json file: $outputPath "
142+ $outDir = Split-Path $outputPath - parent
143+ if (-not (Test-Path - path $outDir ))
115144 {
116- if ($pkg.Name ) {
117- Write-Host " Package Name: $ ( $pkg.Name ) "
118- Write-Host " Package Version: $ ( $pkg.Version ) "
119- Write-Host " Package SDK Type: $ ( $pkg.SdkType ) "
120- Write-Host " Artifact Name: $ ( $pkg.ArtifactName ) "
121- Write-Host " Release date: $ ( $pkg.ReleaseStatus ) "
122- $configFilePrefix = $pkg.Name
123- if ($pkg.ArtifactName )
124- {
125- $configFilePrefix = $pkg.ArtifactName
126- }
127- $outputPath = Join-Path - Path $outDirectory " $configFilePrefix .json"
128- Write-Host " Output path of json file: $outputPath "
129- $outDir = Split-Path $outputPath - parent
130- if (-not (Test-Path - path $outDir ))
131- {
132- Write-Host " Creating directory $ ( $outDir ) for json property file"
133- New-Item - ItemType Directory - Path $outDir
134- }
135-
136- # If package properties for a track 2 (IsNewSdk = true) package has
137- # already been written, skip writing to that same path.
138- if ($exportedPaths.ContainsKey ($outputPath ) -and $exportedPaths [$outputPath ].IsNewSdk -eq $true ) {
139- Write-Host " Track 2 package info with file name $ ( $outputPath ) already exported. Skipping export."
140- continue
141- }
142- $exportedPaths [$outputPath ] = $pkg
143-
144- SetOutput $outputPath $pkg
145- }
145+ Write-Host " Creating directory $ ( $outDir ) for json property file"
146+ New-Item - ItemType Directory - Path $outDir | Out-Null
146147 }
147148
148- Get-ChildItem - Path $outDirectory
149- }
150- else
151- {
152- Write-Error " Package properties are not available for service directory $serviceDirectory or $prdiff "
153- exit 1
149+ # If package properties for a track 2 (IsNewSdk = true) package has
150+ # already been written, skip writing to that same path.
151+ if ($exportedPaths.ContainsKey ($outputPath ) -and $exportedPaths [$outputPath ].IsNewSdk -eq $true ) {
152+ Write-Host " Track 2 package info with file name $ ( $outputPath ) already exported. Skipping export."
153+ continue
154+ }
155+ $exportedPaths [$outputPath ] = $pkg
156+
157+ SetOutput $outputPath $pkg
158+ }
154159}
160+
161+ Get-ChildItem - Path $outDirectory
0 commit comments