Skip to content

Commit 9b1d53e

Browse files
committed
Fix cleanup
1 parent 6d118a2 commit 9b1d53e

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

General/Install-PowerShellAsDotNetTool.ps1

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
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.
1518
if ( (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.
4241
try {
4342
dotnet tool install --global PowerShell
4443
$env:PATH += ';' + [System.IO.Path]::Combine($HOME, '.dotnet', 'tools')
@@ -47,7 +46,7 @@ try {
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

Comments
 (0)