diff --git a/eng/common/pipelines/templates/archetype-typespec-emitter.yml b/eng/common/pipelines/templates/archetype-typespec-emitter.yml index c359c3b1ae..5992e40df3 100644 --- a/eng/common/pipelines/templates/archetype-typespec-emitter.yml +++ b/eng/common/pipelines/templates/archetype-typespec-emitter.yml @@ -259,27 +259,38 @@ extends: displayName: Download pipeline artifacts - pwsh: | - npm install -g @azure-tools/typespec-client-generator-cli@latest + npm ci displayName: Install tsp-client + workingDirectory: $(Build.SourcesDirectory)/eng/common/tsp-client + + - pwsh: | + # Resolve EmitterPackageJsonOutputPath to absolute path if it's relative + $emitterPath = '${{ parameters.EmitterPackageJsonOutputPath }}' + if (-not [System.IO.Path]::IsPathRooted($emitterPath)) { + $emitterPath = Join-Path '$(Build.SourcesDirectory)' $emitterPath + } + Write-Host "##vso[task.setvariable variable=ResolvedEmitterPath]$emitterPath" + displayName: Resolve emitter package path + workingDirectory: $(Build.SourcesDirectory) - pwsh: | Write-Host "Overrides location: $(buildArtifactsPath)/packages/overrides.json" + Write-Host "Resolved emitter package path: $(ResolvedEmitterPath)" if (Test-Path -Path '$(buildArtifactsPath)/packages/overrides.json') { Write-Host "Using overrides.json to generate emitter-package.json" - tsp-client generate-config-files ` - --package-json '$(buildArtifactsPath)/lock-files/package.json' ` - --emitter-package-json-path '${{ parameters.EmitterPackageJsonOutputPath }}' ` - --overrides '$(buildArtifactsPath)/packages/overrides.json' + npm exec --no -- tsp-client generate-config-files ` + --package-json '$(buildArtifactsPath)/lock-files/package.json' ` + --emitter-package-json-path '$(ResolvedEmitterPath)' ` + --overrides '$(buildArtifactsPath)/packages/overrides.json' } else { Write-Host "No overrides.json found. Running tsp-client without overrides." - - tsp-client generate-config-files ` - --package-json '$(buildArtifactsPath)/lock-files/package.json' ` - --emitter-package-json-path '${{ parameters.EmitterPackageJsonOutputPath }}' + npm exec --no -- tsp-client generate-config-files ` + --package-json '$(buildArtifactsPath)/lock-files/package.json' ` + --emitter-package-json-path '$(ResolvedEmitterPath)' } displayName: Generate emitter-package.json and emitter-package-lock files - workingDirectory: $(Build.SourcesDirectory) + workingDirectory: $(Build.SourcesDirectory)/eng/common/tsp-client - ${{ parameters.InitializationSteps }}