Introducing PowerShell as .NET Global Tool
PowerShell is very suitable for CI/CD scenarios due to its easy and well understood scripting paradigm,
and its cross-platform support makes it great for building and testing cross-platform applications.
A .NET Global Tool is a special NuGet package that contains a console application.
.NET Core application can be developed for various platforms like Windows, various distributions of Linux and macOS, while the same PowerShell scripts can be used for building, testing and deployment across all platforms.
Installing PowerShell Global tool
If you already have the .NET Core SDK installed, it’s easy to install PowerShell as a .NET global tool!
dotnet tool install --global PowerShell
Once installed, you can run it with
PowerShell in .NET SDK docker containers
PowerShell has already been included as a global tool within the .NET Core 3.0 Preview Docker images since Preview.4.
These images are a great starting point for building a .NET Core CI/CD image
(you can find some awesome samples
over at the
Docker files with PowerShell syntax
As PowerShell comes pre-installed, Docker files can have PowerShell syntax.
This allows you to run scripts or cmdlets as part of your Docker file.
FROM mcr.microsoft.com/dotnet/core/sdk:3.0 RUN pwsh -c Get-Date RUN pwsh -c "Get-Module -ListAvailable | Select-Object -Property Name, Path"
Build scenarios in Docker
In addition to enabling PowerShell syntax, PowerShell scripts in the container can be easily invoked through Docker:
docker run -it -v c:\myrepo:/myrepo -w /myrepo mcr.microsoft.com/dotnet/core/sdk:3.0 pwsh ./build.ps1
The NuGet package for the global tool can be found at: https://www.nuget.org/packages/PowerShell/
Please report issues or suggestions at: https://github.com/PowerShell/PowerShell/issues/new/choose
Senior Software Engineer