Azure / Azure/autorest.powershell

Error run build-module.ps1 when powershell is installed via `dotnet tool install`

Open
#760 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C#
Stars
123
Forks
99
PR merge metrics
No merged PRs in 30d

Description

If PowerShell is installed as a dotnet tool via `dotnet tool install powershell --global`, when running any `build-module.ps1`, I will get this error:

```
PS C:\Users\yeliu\code\azure-powershell\src\Websites\Websites.Autorest> .\build-module.ps1
Creating isolated process...
Unknown option: -NonInteractive
Unknown option: -NoLogo
Unknown option: -NoProfile
Unknown option: -File
.NET SDK (5.0.201)
Usage: dotnet [runtime-options] [path-to-application] [arguments]
```

It seems the script runs dotnet.exe when it should run pwsh.exe

## Root cause
In `build-module.ps1` it tries to get full path to pwsh executable by
```
$pwsh = [System.Diagnostics.Process]::GetCurrentProcess().Path
```
but it returns `C:\Program Files\dotnet\dotnet.exe`
We need to find a correct way to locate pwsh executable

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.