@@ -20,15 +20,21 @@ enum VersionState {
2020 EqualToFeed
2121 NotOnFeed
2222}
23+ $Error.Clear ()
2324$ErrorActionPreference = ' Continue'
2425if ($PSEdition -ne ' Core' ) {
2526 Write-Error ' This script requires PowerShell Core to execute. [Note] Generated cmdlets will work in both PowerShell Core or Windows PowerShell.'
2627}
28+ # Module import.
29+ Import-Module PowerShellGet
30+
2731# Install Powershell-yaml
2832if (! (Get-Module - Name powershell- yaml - ListAvailable)) {
2933 Install-Module powershell- yaml - Force
3034}
3135
36+ # Set NODE max memory to 8 Gb.
37+ $ENV: NODE_OPTIONS = ' --max-old-space-size=8192'
3238$ModulePrefix = " Microsoft.Graph"
3339$ScriptRoot = $PSScriptRoot
3440$ModulesOutputDir = Join-Path $ScriptRoot " ..\src\"
@@ -130,7 +136,8 @@ $ModulesToGenerate | ForEach-Object -ThrottleLimit $ModulesToGenerate.Count -Par
130136 # Generate PowerShell modules.
131137 & autorest -- module- version:$ModuleVersion -- service- name:$ModuleName $ModuleLevelReadMePath -- version:" 3.0.6306" -- verbose
132138 if ($LASTEXITCODE ) {
133- Write-Error " Failed to generate '$ModuleName ' module."
139+ Write-Error " AutoREST failed to generate '$ModuleName ' module."
140+ break ;
134141 }
135142 Write-Host - ForegroundColor Green " AutoRest generated '$FullyQualifiedModuleName ' successfully."
136143
@@ -192,10 +199,6 @@ $ModulesToGenerate | ForEach-Object -ThrottleLimit $ModulesToGenerate.Count -Par
192199 }
193200 $updatedLine
194201 } | Set-Content $InternalModulePsm1
195-
196- if ($LASTEXITCODE ) {
197- Write-Error " Failed to build '$ModuleName ' module."
198- }
199202 }
200203
201204 if ($Using :Test ) {
@@ -206,14 +209,21 @@ $ModulesToGenerate | ForEach-Object -ThrottleLimit $ModulesToGenerate.Count -Par
206209 # Pack generated module.
207210 . $Using :PackModulePS1 - Module $ModuleName - ArtifactsLocation $Using :ArtifactsLocation
208211 }
212+
213+ Write-Host - ForeGroundColor Green " Generating $ModuleName Completed"
209214 }
210215 catch {
211- throw $_
216+ Write-Error $_
212217 }
213- Write-Host - ForeGroundColor Green " Generating $ModuleName Completed"
214218 }
215219}
216220
221+ if ($Error.Count -ge 1 ) {
222+ # Write generation errors to pipeline.
223+ $Error
224+ Write-Error " The SDK failed to build due to $ ( $Error.Count ) errors listed above." - ErrorAction " Stop"
225+ }
226+
217227if ($Publish ) {
218228 # Publish generated modules.
219229 & $PublishModulePS1 - Modules $ModuleMapping.Keys - ModulePrefix $ModulePrefix - ArtifactsLocation $ArtifactsLocation - RepositoryName $RepositoryName - RepositoryApiKey $RepositoryApiKey
0 commit comments