Introducing PowerShell as .NET Global Tool

Server Man

Well-Known Member
May 17, 2015
Windows 7
Firefox 43.0
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.

A .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 pwsh.

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 dotnet-docker repo.)

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: PowerShell 6.2.2

Please report issues or suggestions at: Build software better, together

Thank you!

Aditya Patwardhan
Senior Software Engineer
PowerShell Team
@adityapatward13


The post Introducing PowerShell as .NET Global Tool appeared first on PowerShell.

Continue reading...
 

Similar threads

S
Replies
0
Views
18
Steve Clarke, Editor
S
B
Replies
0
Views
68
Brandon LeBlanc
B
B
Replies
0
Views
76
Brandon LeBlanc
B
B
Replies
0
Views
137
Brandon LeBlanc
B
Back
Top Bottom