-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vcpkg.targets outputs error message in success case for pwsh.exe search #38502
Comments
@davidmatson Thanks for posting this issue, could you please provide me with the error log you output?
This will only cover up the error but not fix it. 🤔 |
Sure; the error message is simply:
I think the problem is just that the current command attempts to invoke a program that may or may not exist, and then uses the exit code to tell whether it did or not, but that command will naturally error out if the program doesn't exist. If the command is intended just to see if it will fail or not, having the "error" message output isn't great. Another option would be to use where:
But redirecting stderr is still necessary; where also outputs text to stderr if the program does not exist. |
I think the following code can serve as a temporary workaround. <!-- Search %PATH% for pwsh.exe if it is available. -->
<Exec
Condition="'$(VcpkgXUseBuiltInApplocalDeps)' != 'true'"
Command="pwsh.exe $(_ZVcpkgAppLocalPowerShellCommonArguments) 2>NUL"
IgnoreExitCode="true"
May I make a pull request? |
The cause of the bug lies in the following part. vcpkg/scripts/buildsystems/msbuild/vcpkg.targets Lines 226 to 231 in ad25766
At line 229, it incorrectly calls On Windows, when you want to check if a specific command is in the By inserting the following code snippet before line 229, the bug can be resolved. Command="where.exe pwsh.exe >NUL 2>&1"
IgnoreExitCode="true"
UseCommandProcessor="false">
<Output TaskParameter="ExitCode"
PropertyName="_ZSearchPwshInPathExitCode" />
</Exec>
<!-- Execute PowerShell Core commands to ensure compatibility with legacy code. -->
<Exec
Condition="'$(_ZSearchPwshInPathExitCode)' == '0'" |
At line 229, just rename from pwsh.exe to powershell.exe |
Describe the bug
When building using scripts\buildsystems\msbuild\vcpkg.targets and using Windows PowerShell (rather than PowerShell Core), the build outputs an error message when it actually succeeds.
Environment
To Reproduce
Steps to reproduce the behavior:
Expected behavior
No error message appears.
Additional context
I suspect the code here is the root cause:
Updating that code to use something like
appears likely to fix the problem.
The text was updated successfully, but these errors were encountered: