{"id":17920,"date":"2019-07-18T16:38:18","date_gmt":"2019-07-19T00:38:18","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/powershell\/?p=17920"},"modified":"2019-07-18T16:38:18","modified_gmt":"2019-07-19T00:38:18","slug":"introducing-powershell-as-net-global-tool","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/introducing-powershell-as-net-global-tool\/","title":{"rendered":"Introducing PowerShell as .NET Global Tool"},"content":{"rendered":"<div class=\"markdown-body\">\n<p>PowerShell is very suitable for CI\/CD scenarios due to its easy and well understood scripting paradigm,\nand its cross-platform support makes it great for building and testing cross-platform applications.\nA <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/core\/tools\/global-tools\" rel=\"nofollow\">.NET Global Tool<\/a> is a special NuGet package that contains a console application.<\/p>\n<p>A <code>.NET Core<\/code> 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.<\/p>\n<h2><a id=\"user-content-installing-powershell-global-tool\" class=\"anchor\" href=\"#installing-powershell-global-tool\" aria-hidden=\"true\"><\/a>Installing PowerShell Global tool<\/h2>\n<p>If you already have the .NET Core SDK installed, it&#8217;s easy to install PowerShell as a .NET global tool!<\/p>\n<pre class=\"powershell-console\"><code>dotnet tool install --global PowerShell\r\n<\/code><\/pre>\n<p>Once installed, you can run it with <code>pwsh<\/code>.<\/p>\n<h2><a id=\"user-content-powershell-in-net-sdk-docker-containers\" class=\"anchor\" href=\"#powershell-in-net-sdk-docker-containers\" aria-hidden=\"true\"><\/a>PowerShell in .NET SDK docker containers<\/h2>\n<p>PowerShell has already been included as a global tool within the <a href=\"https:\/\/hub.docker.com\/_\/microsoft-dotnet-core-sdk\/\" rel=\"nofollow\">.NET Core 3.0 Preview Docker images<\/a> since Preview.4.\nThese images are a great starting point for building a .NET Core CI\/CD image\n(you can find some <a href=\"https:\/\/github.com\/dotnet\/dotnet-docker\/tree\/master\/samples\/dotnetapp\">awesome samples<\/a>\nover at the <code>dotnet-docker<\/code> repo.)<\/p>\n<h3><a id=\"user-content-docker-files-with-powershell-syntax\" class=\"anchor\" href=\"#docker-files-with-powershell-syntax\" aria-hidden=\"true\"><\/a>Docker files with PowerShell syntax<\/h3>\n<p>As PowerShell comes pre-installed, Docker files can have PowerShell syntax.\nThis allows you to run scripts or cmdlets as part of your Docker file.<\/p>\n<pre lang=\"docker\"><code>FROM mcr.microsoft.com\/dotnet\/core\/sdk:3.0\r\nRUN pwsh -c Get-Date\r\nRUN pwsh -c \"Get-Module -ListAvailable | Select-Object -Property Name, Path\"\r\n<\/code><\/pre>\n<h3><a id=\"user-content-build-scenarios-in-docker\" class=\"anchor\" href=\"#build-scenarios-in-docker\" aria-hidden=\"true\"><\/a>Build scenarios in Docker<\/h3>\n<p>In addition to enabling PowerShell syntax, PowerShell scripts in the container can be easily invoked through Docker:<\/p>\n<pre class=\"powershell-console\"><code>docker run -it -v c:\\myrepo:\/myrepo -w \/myrepo mcr.microsoft.com\/dotnet\/core\/sdk:3.0 pwsh .\/build.ps1\r\n<\/code><\/pre>\n<p>The NuGet package for the global tool can be found at: <a href=\"https:\/\/www.nuget.org\/packages\/PowerShell\/\" rel=\"nofollow\">https:\/\/www.nuget.org\/packages\/PowerShell\/<\/a><\/p>\n<p>Please report issues or suggestions at: <a href=\"https:\/\/github.com\/PowerShell\/PowerShell\/issues\/new\/choose\">https:\/\/github.com\/PowerShell\/PowerShell\/issues\/new\/choose<\/a><\/p>\n<p>Thank you!<\/p>\n<p>Aditya Patwardhan\nSenior Software Engineer\nPowerShell Team\n<a href=\"https:\/\/twitter.com\/adityapatward13\" rel=\"nofollow\">@adityapatward13<\/a><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>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, [&hellip;]<\/p>\n","protected":false},"author":6045,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-17920","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"blog_post_summary":"<p>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, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/17920","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/6045"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=17920"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/17920\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=17920"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=17920"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=17920"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}