how to use Powershell in runtime:6.0 #3930
Answered
by
mthalman
shengzhizhou
asked this question in
Q&A
-
Hi, I'm working on a new .NET 6 project and I need to call some powershell scripts in program. I notice runtime:6.0 doesn't have PowerShell built-in. I know sdk:6.0 has built-in PowerShell but the image size will be much larger as final image. What else can I do? How can I achieve that? Thanks for answers! |
Beta Was this translation helpful? Give feedback.
Answered by
mthalman
Jul 19, 2022
Replies: 1 comment 3 replies
-
You can grab it out of the sdk image like this: LinuxFROM mcr.microsoft.com/dotnet/runtime:6.0
COPY --from=mcr.microsoft.com/dotnet/sdk:6.0 /usr/share/powershell /usr/share/powershell
RUN ln -s /usr/share/powershell/pwsh /usr/bin/pwsh WindowsFROM mcr.microsoft.com/dotnet/runtime:6.0
COPY --from=mcr.microsoft.com/dotnet/sdk:6.0 [ "/Program Files/powershell", "/Program Files/powershell" ]
COPY --from=mcr.microsoft.com/dotnet/sdk:6.0 [ "/Program Files/dotnet/shared/Microsoft.WindowsDesktop.App", "/Program Files/dotnet/shared/Microsoft.WindowsDesktop.App" ]
# In order to set system PATH, ContainerAdministrator must be used
USER ContainerAdministrator
RUN setx /M PATH "%PATH%;C:\Program Files\powershell"
USER ContainerUser |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
shengzhizhou
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can grab it out of the sdk image like this:
Linux
Windows