Skip to content

Commit 2863858

Browse files
Fix: Don't change working directory when invoking tsp-client (#53156)
* Initial plan * Fix: Don't change working directory when invoking tsp-client Replace Push-Location/Pop-Location with npm --prefix option to avoid changing the working directory before invoking tsp-client. This fixes the issue where tsp-client makes assumptions based on the working directory. Co-authored-by: JoshLove-msft <[email protected]> * Use full path to tsp-client binary instead of npm exec Keep Push-Location for npm ci as required, but execute tsp-client using the full path to the binary. This ensures npm ci runs from the correct directory while tsp-client executes from the current working directory. Co-authored-by: JoshLove-msft <[email protected]> * Use npm exec --prefix to invoke tsp-client Keep Push-Location/Pop-Location for npm ci, then use npm exec --prefix to invoke tsp-client from the current working directory while using the pinned version from tsp-client directory. Co-authored-by: JoshLove-msft <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: JoshLove-msft <[email protected]>
1 parent 6d493fa commit 2863858

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

eng/scripts/Invoke-GenerateAndBuildV2.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,19 @@ if ($relatedTypeSpecProjectFolder) {
140140
Write-Error "Failed to install tsp-client dependencies"
141141
exit $LASTEXITCODE
142142
}
143-
144-
# Use tsp-client from pinned version by running from tsp-client directory
145-
$tspclientCommand = "npm exec --no -- tsp-client init --update-if-exists --tsp-config $tspConfigFile --repo $repo --commit $commitid"
146-
if ($swaggerDir) {
147-
$tspclientCommand += " --local-spec-repo $typespecFolder"
148-
}
149-
Write-Host $tspclientCommand
150-
Invoke-Expression $tspclientCommand
151143
}
152144
finally {
153145
Pop-Location
154146
}
155147

148+
# Use tsp-client from pinned version by passing --prefix to use tsp-client from that directory
149+
$tspclientCommand = "npm exec --prefix $tspClientDir --no -- tsp-client init --update-if-exists --tsp-config $tspConfigFile --repo $repo --commit $commitid"
150+
if ($swaggerDir) {
151+
$tspclientCommand += " --local-spec-repo $typespecFolder"
152+
}
153+
Write-Host $tspclientCommand
154+
Invoke-Expression $tspclientCommand
155+
156156
if ($LASTEXITCODE) {
157157
# If Process script call fails, then return with failure to CI and don't need to call GeneratePackage
158158
Write-Host "[ERROR] Failed to generate typespec project:$typespecFolder. Exit code: $LASTEXITCODE. Please review the detail errors for potential fixes. If the issue persists, contact the DotNet language support channel at $DotNetSupportChannelLink and include this spec pull request."

0 commit comments

Comments
 (0)