From a88dd9aef348d3e2b02b713a873be486c8edb032 Mon Sep 17 00:00:00 2001 From: "Mingzhe Huang (from Dev Box)" Date: Sat, 12 Oct 2024 12:55:22 +0800 Subject: [PATCH] fix `Test-Package.ps1` --- packages/http-client-csharp/eng/scripts/Generate.ps1 | 6 ++++-- packages/http-client-csharp/eng/scripts/Generation.psm1 | 7 +++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/http-client-csharp/eng/scripts/Generate.ps1 b/packages/http-client-csharp/eng/scripts/Generate.ps1 index de0bd2347f..6185449403 100644 --- a/packages/http-client-csharp/eng/scripts/Generate.ps1 +++ b/packages/http-client-csharp/eng/scripts/Generate.ps1 @@ -9,6 +9,8 @@ Import-Module "$PSScriptRoot\Generation.psm1" -DisableNameChecking -Force; $packageRoot = Resolve-Path (Join-Path $PSScriptRoot '..' '..') $solutionDir = Join-Path $packageRoot 'generator' +# absolute path to locally built emitter module +$emitterPath = Resolve-Path (Join-Path $PSScriptRoot '..' '..' 'dist' 'emitter\') if (-not $LaunchOnly) { Refresh-Build @@ -20,7 +22,7 @@ if (-not $LaunchOnly) { $unbrandedTypespecTestProject = Join-Path $testProjectsLocalDir "Unbranded-TypeSpec" $unbrandedTypespecTestProject = $unbrandedTypespecTestProject - Invoke (Get-TspCommand "$unbrandedTypespecTestProject/Unbranded-TypeSpec.tsp" $unbrandedTypespecTestProject) + Invoke (Get-TspCommand "$unbrandedTypespecTestProject/Unbranded-TypeSpec.tsp" $unbrandedTypespecTestProject $false $emitterPath) # exit if the generation failed if ($LASTEXITCODE -ne 0) { @@ -124,7 +126,7 @@ foreach ($directory in $directories) { continue } Write-Host "Generating $subPath" -ForegroundColor Cyan - Invoke (Get-TspCommand $specFile $generationDir $stubbed) + Invoke (Get-TspCommand $specFile $generationDir $stubbed $emitterPath) # exit if the generation failed if ($LASTEXITCODE -ne 0) { diff --git a/packages/http-client-csharp/eng/scripts/Generation.psm1 b/packages/http-client-csharp/eng/scripts/Generation.psm1 index 6720dba72d..5cefe7ff26 100644 --- a/packages/http-client-csharp/eng/scripts/Generation.psm1 +++ b/packages/http-client-csharp/eng/scripts/Generation.psm1 @@ -1,6 +1,4 @@ $repoRoot = Resolve-Path (Join-Path $PSScriptRoot '..') -# absolute path to locally built emitter module -$emitterPath = Resolve-Path (Join-Path $PSScriptRoot '..' '..' 'dist' 'emitter\') function Invoke($command, $executePath=$repoRoot) { @@ -26,11 +24,12 @@ function Get-TspCommand { param ( [string]$specFile, [string]$generationDir, - [bool]$generateStub = $false + [bool]$generateStub = $false, + [string]$emitterNameOrPath = "@typespec/http-client-csharp" ) $command = "npx tsp compile $specFile" $command += " --trace @typespec/http-client-csharp" - $command += " --emit $emitterPath" + $command += " --emit $emitterNameOrPath" $configFile = Join-Path $generationDir "tspconfig.yaml" if (Test-Path $configFile) { $command += " --config=$configFile"