conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.22k stars 979 forks source link

[feature] powershell generation in VirtualBuildEnv/VirtualRunEnv #9898

Closed mjvankampen closed 2 years ago

mjvankampen commented 2 years ago

Currently only shell and bat scripts are generated. On Windows I mainly use powershell, even on Linux I use powershell quite a bit as it is cross platform.

memsharded commented 2 years ago

Hi @mjvankampen

Yes, you are right. We have been delaying this because we know very little PS and we struggled at the first try. Some help here would be very appreciated, and if nobody contributes it, we will try to add them when possible (not a huge priority now, because we are focused on validating that the big picture of this new environment, together with all the new integrations is working)

abrousseau001 commented 2 years ago

One of the major issues I have found with PowerShell is its quoting over commands stored as variables or even using variables to build parts of a command to execute at some later point. I have built Apache Httpd with FIPS 140-2 compliance for a project and ended up scrapping PowerShell in favour of just simple batch scripts in Windows.

The other issue I have had involves the security policies surrounding PowerShell scripts. While a developer might be ok in temporarily setting a policy that allows bypassing the security of scripts, many IT centric organisations prevent that as it becomes a security concern.

I apologize if my information is too Windows specific, but I have had the battle using PowerShell and just want to throw in my two cents when considering wider adoption.

memsharded commented 2 years ago

The other issue I have had involves the security policies surrounding PowerShell scripts. While a developer might be ok in temporarily setting a policy that allows bypassing the security of scripts, many IT centric organisations prevent that as it becomes a security concern.

I agree with that. Even my own machine has policies so the PS tests fails in my machine. I suggest that all PS features are opt-in, but not the default.

memsharded commented 2 years ago

BTW, @tapia fixed PS generation in https://github.com/conan-io/conan/pull/10049. Now it is still missing some UI to be able to opt-in using it.

SpaceIm commented 2 years ago

Maybe I miss something, but when I use VirtualBuildEnv and VirtualRunEnv with conan 1.43.0, I don't see any generated ps script, only bat files which don't propagate env vars in the powershell context.

tapia commented 2 years ago

I don't see any generated ps script, only bat files which don't propagate env vars in the powershell context.

You're right, @SpaceIm, I'm deleting the 1.43 comment to avoid confusion.

The code to generate the PS script is there in 1.43 (save_ps1() in conan/tools/env/environment.py), but we didn't update VirtualRunEnv to actually generate it. As Diego said, there's still some UI work to do. I hope I can get to do it for 1.44.

memsharded commented 2 years ago

https://github.com/conan-io/conan/pull/11061 added support for not only generating, but also using in Conan ps1 scripts instead of bat

Inujel commented 1 year ago

Is there a reason why this feature is opt-in?

Enabling it by default would be one less thorn in the side of those who work with Powershell.

memsharded commented 1 year ago

Powershell is a bit more tricky that .bat files, less mature (the integration, we have less expertise in it) so it can have more bugs and issues, etc.. Also not all Windows users have expertise in it, while most of them know .bat files, so it seems the correct default is .bat files, and having .ps1 as opt-in.

Inujel commented 1 year ago

Alright, thanks for the answer!