Skip to content

Commit b6b8a3a

Browse files
chidozieononiwubenbp
authored andcommitted
Update dotnet docs logic in tools repo to prevent overwrite when sync happens (#1022)
1 parent 3792186 commit b6b8a3a

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

eng/common/scripts/copy-docs-to-blobstorage.ps1

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -257,30 +257,31 @@ if ($Language -eq "javascript")
257257

258258
if ($Language -eq "dotnet")
259259
{
260-
$PublishedPkgs = Get-ChildItem "$($DocLocation)/packages" | Where-Object -FilterScript {$_.Name.EndsWith(".nupkg") -and -not $_.Name.EndsWith(".symbols.nupkg")}
261-
$PublishedDocs = Get-ChildItem "$($DocLocation)" | Where-Object -FilterScript {$_.Name.StartsWith("Docs.")}
260+
$PublishedPkgs = Get-ChildItem "$($DocLocation)" | Where-Object -FilterScript {$_.Name.EndsWith(".nupkg") -and -not $_.Name.EndsWith(".symbols.nupkg")}
261+
$PublishedDocs = Get-ChildItem "$($DocLocation)" | Where-Object -FilterScript {$_.Name.EndsWith("docs.zip")}
262262

263-
foreach ($Item in $PublishedDocs) {
264-
$PkgName = $Item.Name.Remove(0, 5)
265-
$PkgFullName = $PublishedPkgs | Where-Object -FilterScript {$_.Name -match "$($PkgName).\d"}
266-
267-
if (($PkgFullName | Measure-Object).count -eq 1)
268-
{
269-
$DocVersion = $PkgFullName[0].BaseName.Remove(0, $PkgName.Length + 1)
270-
271-
Write-Host "Start Upload for $($PkgName)/$($DocVersion)"
272-
Write-Host "DocDir $($Item)"
273-
Write-Host "PkgName $($PkgName)"
274-
Write-Host "DocVersion $($DocVersion)"
275-
$releaseTag = RetrieveReleaseTag "Nuget" $PublicArtifactLocation
276-
Upload-Blobs -DocDir "$($Item)" -PkgName $PkgName -DocVersion $DocVersion -ReleaseTag $releaseTag
277-
}
278-
else
279-
{
280-
Write-Host "Package with the same name Exists. Upload Skipped"
281-
continue
282-
}
263+
if (($PublishedPkgs.Count -gt 1) -or ($PublishedDoc.Count -gt 1))
264+
{
265+
Write-Host "$($DocLocation) should contain only one (1) published package and docs"
266+
Write-Host "No of Packages $($PublishedPkgs.Count)"
267+
Write-Host "No of Docs $($PublishedDoc.Count)"
268+
exit 1
283269
}
270+
271+
$DocsStagingDir = "$WorkingDirectory/docstaging"
272+
$TempDir = "$WorkingDirectory/temp"
273+
274+
New-Item -ItemType directory -Path $DocsStagingDir
275+
New-Item -ItemType directory -Path $TempDir
276+
277+
Expand-Archive -LiteralPath $PublishedDocs[0].FullName -DestinationPath $DocsStagingDir
278+
$pkgProperties = ParseNugetPackage -pkg $PublishedPkgs[0].FullName -workingDirectory $TempDir
279+
280+
Write-Host "Start Upload for $($pkgProperties.ReleaseTag)"
281+
Write-Host "DocDir $($DocsStagingDir)"
282+
Write-Host "PkgName $($pkgProperties.PackageId)"
283+
Write-Host "DocVersion $($pkgProperties.PackageVersion)"
284+
Upload-Blobs -DocDir "$($DocsStagingDir)" -PkgName $pkgProperties.PackageId -DocVersion $pkgProperties.PackageVersion -ReleaseTag $pkgProperties.ReleaseTag
284285
}
285286

286287
if ($Language -eq "python")

0 commit comments

Comments
 (0)