microsoft / powerplatform-build-tools

Power Platform Build Tools automate common build and deployment tasks related to Power Platform. This includes synchronization of solution metadata (a.k.a. solutions) between development environments and source control, generating build artifacts, deploying to downstream environments, provisioning/de-provisioning of environments, and the ability to perform static analysis checks against your solution using the PowerApps checker service.
MIT License
186 stars 38 forks source link

pac.launcher.exe does not return correct exit code #912

Open Zerajima opened 3 months ago

Zerajima commented 3 months ago

I have installed pac tool with .msi package. This installs it to "%USERPROFILE%\AppData\Local\Microsoft\PowerAppsCli". This folder is also added to PATH variable. When I invoke pac from command line, it actually invokes pac.bat, which invokes pac.launcher.exe. I assume this application is responsible for figuring out which version of pac tool should be invoked, since multiple can be installed at the same time.

However, this application does not return an error code from pac tool, if one is thrown. The exit code of this application is always 0. This makes it hard to use in PowerShell scripts.

Is there some other way I can detect errors, when invoking pac from PowerShell?

petrochuk commented 3 months ago

the suggested workaround is to invoke "pac.exe" but like you pointed out it is not going to check for latest version which can also a benefit if you run is as part of automated process

Zerajima commented 3 months ago

That means either hard-coding it to exact version, or forcing users into another installation method, which does not come with pac.launcher.exe. I wanted scripts to be usable in automated build system and available to developers on their own machines. But that means, I have to instruct them not to use the .msi package, if they want the scripts to work correctly.

It's extremely annoying, that simply using another installation method, causes the tool to behave differently. It's not what I would have expected.

petrochuk commented 3 months ago

Have you looked at dotnet tool? It installs cross platform version of pac cli built on top of .net core.

https://learn.microsoft.com/en-us/power-platform/developer/cli/introduction?tabs=windows#install-microsoft-power-platform-cli

dotnet tool install --global Microsoft.PowerApps.CLI.Tool
Zerajima commented 3 months ago

I have, but I feel it presents us with a certain danger. As long as my coworkers choose the correct installation method, everything will work as it should. However, if someone installs the .msi package, it will still appear to work correctly, but errors will not be handled properly, which could cause significant problems.

The behavior of the tool should not depend on the installation method.