1111 https://github.com/SamErde/PowerShell/General
1212#>
1313
14+ [CmdletBinding ()]
15+ param ()
16+
1417# Download the .NET CLI install script if it is not found.
1518if ( (Get-Command - Name ' dotnet' - ErrorAction SilentlyContinue) ) {
16- Write-Verbose " dotnet is already installed."
19+ Write-Verbose ' dotnet is already installed.'
1720} else {
1821 $DownloadPath = Join-Path - Path $env: TEMP - ChildPath ' dotnet-install.ps1'
1922 try {
@@ -26,7 +29,6 @@ if ( (Get-Command -Name 'dotnet' -ErrorAction SilentlyContinue) ) {
2629
2730 # Install the dotnet tool. The script installs the latest LTS release by default.
2831 # The current stable release is required for PowerShell 7.5, which depends on .NET 9.
29- # Need to add a check for the appropriate version of .NET.
3032 try {
3133 .$DownloadPath - InstallDir ' ~/.dotnet' - Channel ' STS' # use of 'Current' is deprecated.
3234 } catch {
@@ -35,10 +37,7 @@ if ( (Get-Command -Name 'dotnet' -ErrorAction SilentlyContinue) ) {
3537
3638}
3739
38- dotnet dev- certs https -- trust
39-
4040# Install PowerShell and add $HOME\.dotnet\tools to the PATH.
41- # Need to add error handling for when the required version of .NET is missing.
4241try {
4342 dotnet tool install -- global PowerShell
4443 $env: PATH += ' ;' + [System.IO.Path ]::Combine($HOME , ' .dotnet' , ' tools' )
4746}
4847
4948# Clean up.
50- Remove-Variable - Name DownloadPath
51- if (Test-Path - Path DownloadPath) {
49+ if (Test-Path - Path $DownloadPath ) {
5250 Remove-Item - Path $DownloadPath - Confirm:$false
5351}
52+ Remove-Variable - Name DownloadPath
0 commit comments