.NET Core SDK Docker Images Contain PowerShell Core #3656
Replies: 16 comments
-
|
Beta Was this translation helpful? Give feedback.
-
I'm unable to install anything from the PowerShell Gallery. First, I attempted to install the SharePointSDK from the PowerShell Gallery using Install-Module -Name SharePointSDK -Force Which then threw the following error:
I then attempted to install Nuget...which I attempted to install as follows: Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force Then it threw the following error:
Also this:
NOTE: I do have internet access from within the container which I validated by running a wget. When I go to the command-line of the container, I noticed that get-psrepository and set-psrepository were not available. Thanks. |
Beta Was this translation helpful? Give feedback.
-
Im experiencing the same. Could it be related to: OneGet/oneget#443 Also, on my local machine i have the |
Beta Was this translation helpful? Give feedback.
-
Thank you so much for adding powershell. Also I notice unit testing is not working:
|
Beta Was this translation helpful? Give feedback.
-
Can anyone from Microsoft respond with a status on when we may expect this to work? Having a fully functional .NET Core with a complete implementation of PowerShell core solves a lot of problems for people. Since the current implementation of PowerShell core inside of .NET core seems to be incomplete, we're kind of stuck in limbo despite the exciting announcement in this thread. I work for a large enterprise and we run everything else we need to run inside linux-based containers and we can't even think about Windows containers until OpenShift 4. I'd love to move our reporting tools off our Windows server POSH hosts and I'm certain I'm not the only one that feels this way. |
Beta Was this translation helpful? Give feedback.
-
@adityapatwardhan - Can you help out with the issues reported here with installing modules and package providers? |
Beta Was this translation helpful? Give feedback.
-
I think I recall there being discussions about trimming Powershell in the dotnet image, to focus on the exact use case scenarios they wanted to support, I can't find this discussion at the moment though, maybe it was on twitter? I can say though, that the dotnet docker image definitely makes use of some "custom build" of Powershell I can't exactly find much information about, as such I found that in order to support the scenarios above that it was easier to use the powershell image as a base, which uses the publicly released artifacts on Github, and add dotnet core on top of it. Specifically I used the nanoserver-1809 DockerFile as a reference point to add on top of the powershell nanoserver image. Note, that even so there will still be some quirky behaviour, have not taken a deep dive into it, but installing the SqlServer module will, for example, besides some warning and errors, result in a failure due it failing the digital signature check, obviously I was able to "fix" this by skipping the cert check, but obviously that's dangerous behaviour to do in general. (Please use this information responsibly) Also when getting the module installed, I was also not able to fix the PSModulePath so that you could do "Import-Module SqlServer", instead I had to input the full path to the .psd1-file, e.g. c:\Users\ContainerUser\Documents\Powershell\Modules\SqlServer\SqlServer.psd1 Installing modules as ContainerAdministrator with an install scope of AllUsers might work since that is still in the PSModulePath, but I have not tested this so far. |
Beta Was this translation helpful? Give feedback.
-
We also ended up building off of the powershell image as base, but it would be nice if .net core with pwsh allowed for installing a module provider to pull other dependencies down. |
Beta Was this translation helpful? Give feedback.
-
PowerShell in the dotnet SDK images should support installing packages from gallery. I will have a look at this today. |
Beta Was this translation helpful? Give feedback.
-
We just released PowerShell v7.0.0-preview.1 which is based on netcore3.0. It has the fix for OneGet/oneget#443. @MichaelSimons I can send a PR for updating the PowerShell version today, if you are fine with it. |
Beta Was this translation helpful? Give feedback.
-
@adityapatwardhan, what is the release schedule for v7.0.0? We would want it to release prior to 3.0 if we take a dependency on it. |
Beta Was this translation helpful? Give feedback.
-
Any plans to do the same for .NET Core 2.1 (LTS) SDK Docker container images? |
Beta Was this translation helpful? Give feedback.
-
@lantrix - There are no plans to back port this change. We consider a breaking change from a Docker Image perspective. |
Beta Was this translation helpful? Give feedback.
-
trying is now. hopefully this works.! |
Beta Was this translation helpful? Give feedback.
-
Are the Certificate Modules Included in this image. When i was trying to import a Certificate i get the error "Import-PfxCertificate not recognized as the name of a Cmdlet " ... Cannot even let it import. |
Beta Was this translation helpful? Give feedback.
-
@parveenLily |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
.NET Core 3.0 SDK Docker images now contain PowerShell Core
PowerShell Core has been added to the .NET Core 3.0 SDK Docker container images as part of .NET Core 3.0 Preview 4. PowerShell Core was added as a result of and resolves dotnet/dotnet-docker #360 . It has been added for both Linux and Nano Server container images, but only for SDK images.
PowerShell Core is a cross-platform (Windows, Linux, and macOS) automation and configuration tool/framework that works well with your existing tools and is optimized for dealing with structured data (e.g. JSON, CSV, XML, etc.), REST APIs, and object models. It includes a command-line shell, an associated scripting language and a framework for processing cmdlets.
You can try out PowerShell Core, as part of the .NET Core SDK container image, by running the following Docker command:
docker run --rm mcr.microsoft.com/dotnet/core/sdk:3.0 pwsh -c Write-Host "Hello Powershell"
There are two main scenarios that having PowerShell inside the .NET Core SDK container image enables, which were not otherwise possible:
Example syntax for launching PowerShell for a (volume-mounted) containerized build:
docker run -it -v c:\myrepo:/myrepo -w /myrepo mcr.microsoft.com/dotnet/core/sdk:3.0 pwsh build.ps1
docker run -it -v c:\myrepo:/myrepo -w /myrepo mcr.microsoft.com/dotnet/core/sdk:3.0 ./build.ps1
For the second example to work, on Linux, the
.ps1
file needs to have the following pattern, and needs to be formatted with Unix (LF) not Windows (CRLF) line endings:If you are new to PowerShell and would like to learn more, we recommend reviewing the getting started documentation.
Note: PowerShell Core is now available as part of .NET Core 3.0 SDK container images. It is not part of the .NET Core 3.0 SDK.
Beta Was this translation helpful? Give feedback.
All reactions