Skip to content

Commit

Permalink
Support typespec to sdk preview pipeline (Azure#38576)
Browse files Browse the repository at this point in the history
* Add changes to support typespec preview pipeline

* Revert whitespace changes

* Improve error logging in Update-dotnet-GeneratedSdks
  • Loading branch information
hallipr authored and matthohn-msft committed Oct 27, 2023
1 parent c21559a commit a040666
Showing 1 changed file with 46 additions and 5 deletions.
51 changes: 46 additions & 5 deletions eng/scripts/Language-Settings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ function EnsureCustomSource($package) {
-AllVersions `
-AllowPrereleaseVersions

if (!$? -or !$existingVersions) {
if (!$? -or !$existingVersions) {
Write-Host "Failed to find package $($package.Name) in custom source $customPackageSource"
return $package
}
Expand Down Expand Up @@ -495,19 +495,19 @@ function UpdateDocsMsPackages($DocConfigFile, $Mode, $DocsMetadata) {
continue
}

if ($matchingPublishedPackage.Support -eq 'deprecated') {
if ($Mode -eq 'legacy') {
if ($matchingPublishedPackage.Support -eq 'deprecated') {
if ($Mode -eq 'legacy') {

# Select the GA version, if none use the preview version
$updatedVersion = $matchingPublishedPackage.VersionGA.Trim()
if (!$updatedVersion) {
if (!$updatedVersion) {
$updatedVersion = $matchingPublishedPackage.VersionPreview.Trim()
}
$package.Versions = @($updatedVersion)

Write-Host "Add deprecated package to legacy moniker: $($package.Name)"
$outputPackages += $package
} else {
} else {
Write-Host "Removing deprecated package: $($package.Name)"
}

Expand Down Expand Up @@ -586,3 +586,44 @@ function Get-dotnet-EmitterName() {
function Get-dotnet-EmitterAdditionalOptions([string]$projectDirectory) {
return "--option @azure-tools/typespec-csharp.emitter-output-dir=$projectDirectory/src"
}

function Update-dotnet-GeneratedSdks([string]$PackageDirectoriesFile) {
$showSummary = ($env:SYSTEM_DEBUG -eq 'true') -or ($VerbosePreference -ne 'SilentlyContinue')
$summaryArgs = $showSummary ? "/v:n /ds" : ""

$packageDirectories = Get-Content $PackageDirectoriesFile | ConvertFrom-Json

$directoriesWithErrors = @()

Invoke-LoggedCommand "npm install -g autorest"

foreach ($directory in $packageDirectories) {
Push-Location $RepoRoot
try {
Write-Host "`n`n======================================================================"
Write-Host "Generating projects under directory '$directory'" -ForegroundColor Yellow
Write-Host "======================================================================`n"

Invoke-LoggedCommand "dotnet msbuild /restore /t:GenerateCode /p:Scope=`"$directory`" $summaryArgs eng\service.proj" -GroupOutput
}
catch {
Write-Host "##[error]Error generating project under directory $directory"
Write-Host $_.Exception.Message
$directoriesWithErrors += $directory
}
finally {
Pop-Location
}
}

if($directoriesWithErrors.Count -gt 0) {
Write-Host "##[error]Generation errors found in $($directoriesWithErrors.Count) directories:"

foreach ($directory in $directoriesWithErrors) {
Write-Host " $directory"
}

exit 1
}

}

0 comments on commit a040666

Please sign in to comment.