-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fix: findVisualStudio with pwsh constrained lang. mode #2449
base: main
Are you sure you want to change the base?
Conversation
'Add-Type' cannot be used in powershell with constrained language mode. Language mode does not exist in PowerShell 2.0 engine. To force powershell to use 2.0 engine allows the usage of msvc 2017 or newer in environment with constrained language mode. See : https://devblogs.microsoft.com/powershell/powershell-constrained-language-mode/ https://docs.microsoft.com/en-us/powershell/scripting/windows-powershell/starting-the-windows-powershell-2.0-engine?view=powershell-7.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This solution also has problems when PS 2.0 isn't installed
C:\Users\smaddock>powershell.exe -Version 2
Encountered a problem reading the registry. Cannot find registry key SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine. The Windows PowerShell 2 engine is not installed on this computer.
a93bf54
to
9d330d1
Compare
I modified the pull request so that the use of the '-Version 2' option is only done when necessary. |
Please rebase and fix git conflicts. |
I found that Get-VSSetupInstance works well - https://github.com/microsoft/vssetup.powershell Here is my gist, but it's very rough with few hard-codes there (to be generalized): Created pull request that is using VSModule #2957 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Best effort!
|
Ok fix not used visual studio . Thanks !
Mayra delapaz
…On Thu, May 23, 2024 at 1:44 AM Christian Clauss ***@***.***> wrote:
Conflicting files: lib/find-visualstudio.js
—
Reply to this email directly, view it on GitHub
<#2449 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BCOM4O6XHVWZJZH7VYEPQ23ZDV62ZAVCNFSM47WKNTV2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMJSGYZDOOJZG44Q>.
PM
You are receiving this because you commented.Message ID:
***@***.***>
|
Can anyone fix this issue as it has a huge impact while building other libraries? @cclauss @jarig @Mapuppy09 |
@bshah007 The change comes from the ticket mentioned above #2957 (merged) |
'Add-Type' cannot be used in powershell with constrained language mode. Language mode does not exist in PowerShell 2.0 engine. To force powershell to use 2.0 engine allows the usage of msvc 2017 or newer in environment with constrained language mode.
See :
https://devblogs.microsoft.com/powershell/powershell-constrained-language-mode/
https://docs.microsoft.com/en-us/powershell/scripting/windows-powershell/starting-the-windows-powershell-2.0-engine?view=powershell-7.1
Checklist
npm install && npm test
passesDescription of change
I added the option '-Version 2' in the powershell command which retrieves the installation data of Visual Studio 2017 (or newer). This option allows you to ignore the constrained language mode since the user does not necessarily have control over this parameter in his environment. This language mode does not allow the use of 'Add-Type', but this powershell applet is currently required to run C # code.